lucid-extension-sdk 0.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.
- package/LICENSE +201 -0
- package/README.md +11 -0
- package/interop.d.ts +8 -0
- package/out/commandtypes.d.ts +426 -0
- package/out/commandtypes.js +2 -0
- package/out/core/checks.d.ts +93 -0
- package/out/core/checks.js +152 -0
- package/out/core/dataerrortype.d.ts +8 -0
- package/out/core/dataerrortype.js +2 -0
- package/out/core/jsonserializable.d.ts +8 -0
- package/out/core/jsonserializable.js +2 -0
- package/out/core/offsettype.d.ts +16 -0
- package/out/core/offsettype.js +30 -0
- package/out/core/serializeddataerror.d.ts +6 -0
- package/out/core/serializeddataerror.js +8 -0
- package/out/core/serializedfields.d.ts +58 -0
- package/out/core/serializedfields.js +37 -0
- package/out/core/shapedatainheritance.d.ts +16 -0
- package/out/core/shapedatainheritance.js +20 -0
- package/out/data/collectionproxy.d.ts +12 -0
- package/out/data/collectionproxy.js +24 -0
- package/out/data/dataerror.d.ts +6 -0
- package/out/data/dataerror.js +10 -0
- package/out/data/dataitemproxy.d.ts +10 -0
- package/out/data/dataitemproxy.js +17 -0
- package/out/data/dataproxy.d.ts +8 -0
- package/out/data/dataproxy.js +12 -0
- package/out/data/datasourceproxy.d.ts +10 -0
- package/out/data/datasourceproxy.js +17 -0
- package/out/document/blockclasses/blockproxyregistry.d.ts +13 -0
- package/out/document/blockclasses/blockproxyregistry.js +9 -0
- package/out/document/blockclasses/erdblockproxy.d.ts +15 -0
- package/out/document/blockclasses/erdblockproxy.js +41 -0
- package/out/document/blockdefinition.d.ts +5 -0
- package/out/document/blockdefinition.js +2 -0
- package/out/document/blockproxy.d.ts +6 -0
- package/out/document/blockproxy.js +17 -0
- package/out/document/documentproxy.d.ts +10 -0
- package/out/document/documentproxy.js +19 -0
- package/out/document/elementproxy.d.ts +13 -0
- package/out/document/elementproxy.js +36 -0
- package/out/document/groupproxy.d.ts +11 -0
- package/out/document/groupproxy.js +18 -0
- package/out/document/itemproxy.d.ts +21 -0
- package/out/document/itemproxy.js +55 -0
- package/out/document/linedefinition.d.ts +27 -0
- package/out/document/linedefinition.js +2 -0
- package/out/document/lineproxy.d.ts +25 -0
- package/out/document/lineproxy.js +110 -0
- package/out/document/mapproxy.d.ts +15 -0
- package/out/document/mapproxy.js +49 -0
- package/out/document/pagedefinition.d.ts +3 -0
- package/out/document/pagedefinition.js +2 -0
- package/out/document/pageproxy.d.ts +23 -0
- package/out/document/pageproxy.js +47 -0
- package/out/document/shapedataproxy.d.ts +12 -0
- package/out/document/shapedataproxy.js +45 -0
- package/out/editorclient.d.ts +43 -0
- package/out/editorclient.js +128 -0
- package/out/index.d.ts +7 -0
- package/out/index.js +19 -0
- package/out/math.d.ts +12 -0
- package/out/math.js +24 -0
- package/out/ui/alertmodal.d.ts +8 -0
- package/out/ui/alertmodal.js +37 -0
- package/out/ui/menu.d.ts +26 -0
- package/out/ui/menu.js +42 -0
- package/out/ui/modal.d.ts +36 -0
- package/out/ui/modal.js +69 -0
- package/out/ui/viewport.d.ts +11 -0
- package/out/ui/viewport.js +35 -0
- package/package.json +15 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ERDBlockProxy = exports.ERDFieldProxy = void 0;
|
|
4
|
+
const blockproxy_1 = require("../blockproxy");
|
|
5
|
+
class ERDFieldProxy {
|
|
6
|
+
constructor(block, index) {
|
|
7
|
+
this.block = block;
|
|
8
|
+
this.index = index;
|
|
9
|
+
}
|
|
10
|
+
getName() {
|
|
11
|
+
return this.block.properties.get('Field' + this.index);
|
|
12
|
+
}
|
|
13
|
+
getType() {
|
|
14
|
+
var _a;
|
|
15
|
+
return (_a = this.block.properties.get('Type' + this.index)) !== null && _a !== void 0 ? _a : '';
|
|
16
|
+
}
|
|
17
|
+
getKey() {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = this.block.properties.get('Key' + this.index)) !== null && _a !== void 0 ? _a : '';
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.ERDFieldProxy = ERDFieldProxy;
|
|
23
|
+
class ERDBlockProxy extends blockproxy_1.BlockProxy {
|
|
24
|
+
getName() {
|
|
25
|
+
return this.properties.get('Name');
|
|
26
|
+
}
|
|
27
|
+
getFieldCount() {
|
|
28
|
+
return this.properties.get('Fields');
|
|
29
|
+
}
|
|
30
|
+
getFields() {
|
|
31
|
+
const fields = [];
|
|
32
|
+
const fieldCount = this.getFieldCount();
|
|
33
|
+
for (let i = 1; i <= fieldCount; i++) {
|
|
34
|
+
//These are 1-indexed in the property store
|
|
35
|
+
fields.push(new ERDFieldProxy(this, i));
|
|
36
|
+
}
|
|
37
|
+
return fields;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.ERDBlockProxy = ERDBlockProxy;
|
|
41
|
+
ERDBlockProxy.classNameRegex = /^ERDEntityBlock(2|3|4)?$/;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BlockProxy = void 0;
|
|
4
|
+
const itemproxy_1 = require("./itemproxy");
|
|
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" /* GetConnectedLines */, this.id);
|
|
14
|
+
return ids.map((id) => this.client.getLineProxy(id));
|
|
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 { PageDefinition } from './pagedefinition';
|
|
5
|
+
import { PageProxy } from './pageproxy';
|
|
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,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentProxy = void 0;
|
|
4
|
+
const elementproxy_1 = require("./elementproxy");
|
|
5
|
+
const mapproxy_1 = require("./mapproxy");
|
|
6
|
+
const pageproxy_1 = require("./pageproxy");
|
|
7
|
+
class DocumentProxy extends elementproxy_1.ElementProxy {
|
|
8
|
+
constructor(client) {
|
|
9
|
+
super('', client);
|
|
10
|
+
this.pages = new mapproxy_1.MapProxy(() => this.client.sendCommand("lp" /* ListPages */, undefined), (pageId) => new pageproxy_1.PageProxy(pageId, this.client));
|
|
11
|
+
}
|
|
12
|
+
addPage(def) {
|
|
13
|
+
const id = this.client.sendCommand("cp" /* CreatePage */, undefined);
|
|
14
|
+
const page = new pageproxy_1.PageProxy(id, this.client);
|
|
15
|
+
page.setTitle(def.title);
|
|
16
|
+
return page;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.DocumentProxy = DocumentProxy;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { EditorClient } from '../editorclient';
|
|
2
|
+
import { MapProxy, WriteableMapProxy } from './mapproxy';
|
|
3
|
+
import { ShapeDataProxy } from './shapedataproxy';
|
|
4
|
+
export declare class ElementProxy {
|
|
5
|
+
readonly id: string | undefined;
|
|
6
|
+
protected readonly client: EditorClient;
|
|
7
|
+
readonly properties: WriteableMapProxy<string, import("../core/jsonserializable").JsonSerializable>;
|
|
8
|
+
readonly shapeData: ShapeDataProxy;
|
|
9
|
+
readonly allShapeData: MapProxy<string, import("../core/serializedfields").SerializedFieldType | import("../data/dataerror").DataError>;
|
|
10
|
+
constructor(id: string | undefined, client: EditorClient);
|
|
11
|
+
exists(): boolean;
|
|
12
|
+
executeFormula(formula: string): import("../core/serializedfields").SerializedFieldType | import("../data/dataerror").DataError;
|
|
13
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ElementProxy = void 0;
|
|
4
|
+
const mapproxy_1 = require("./mapproxy");
|
|
5
|
+
const shapedataproxy_1 = require("./shapedataproxy");
|
|
6
|
+
class ElementProxy {
|
|
7
|
+
constructor(id, client) {
|
|
8
|
+
this.id = id;
|
|
9
|
+
this.client = client;
|
|
10
|
+
this.properties = new mapproxy_1.WriteableMapProxy(() => this.client.sendCommand("lpr" /* ListProperties */, { 'id': this.id }), (name) => this.client.sendCommand("gp" /* GetProperty */, {
|
|
11
|
+
'id': this.id,
|
|
12
|
+
'p': name,
|
|
13
|
+
}), (name, value) => {
|
|
14
|
+
if (name === 'BoundingBox') {
|
|
15
|
+
throw new Error('Do not use properties.set() to move or resize items; use setLocation() or setBoundingBox() or offset()');
|
|
16
|
+
}
|
|
17
|
+
this.client.sendCommand("sp" /* SetProperty */, {
|
|
18
|
+
'id': this.id,
|
|
19
|
+
'p': name,
|
|
20
|
+
'v': value,
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
this.shapeData = new shapedataproxy_1.ShapeDataProxy(this.id, this.client);
|
|
24
|
+
this.allShapeData = new mapproxy_1.MapProxy(() => this.client.sendCommand("lsd" /* ListShapeData */, { 'id': this.id, 'i': true }), (name) => shapedataproxy_1.ShapeDataProxy.parseData(this.client.sendCommand("gsd" /* GetShapeData */, {
|
|
25
|
+
'id': this.id,
|
|
26
|
+
'n': name,
|
|
27
|
+
})));
|
|
28
|
+
}
|
|
29
|
+
exists() {
|
|
30
|
+
return this.client.sendCommand("ee" /* ElementExists */, { 'id': this.id });
|
|
31
|
+
}
|
|
32
|
+
executeFormula(formula) {
|
|
33
|
+
return shapedataproxy_1.ShapeDataProxy.parseData(this.client.sendCommand("ef" /* ExecuteFormula */, { 'id': this.id || '', 'f': formula }));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.ElementProxy = ElementProxy;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ItemProxy } from './itemproxy';
|
|
2
|
+
import { LineProxy } from './lineproxy';
|
|
3
|
+
import { MapProxy } from './mapproxy';
|
|
4
|
+
export declare class GroupProxy extends ItemProxy {
|
|
5
|
+
readonly blocks: MapProxy<string, import("./blockproxy").BlockProxy>;
|
|
6
|
+
readonly lines: MapProxy<string, LineProxy>;
|
|
7
|
+
readonly groups: MapProxy<string, GroupProxy>;
|
|
8
|
+
readonly allBlocks: MapProxy<string, import("./blockproxy").BlockProxy>;
|
|
9
|
+
readonly allLines: MapProxy<string, LineProxy>;
|
|
10
|
+
readonly allGroups: MapProxy<string, GroupProxy>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GroupProxy = void 0;
|
|
4
|
+
const itemproxy_1 = require("./itemproxy");
|
|
5
|
+
const lineproxy_1 = require("./lineproxy");
|
|
6
|
+
const mapproxy_1 = require("./mapproxy");
|
|
7
|
+
class GroupProxy extends itemproxy_1.ItemProxy {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.blocks = new mapproxy_1.MapProxy(() => this.client.sendCommand("lb" /* ListBlocks */, { 'id': this.id }), (id) => this.client.getBlockProxy(id));
|
|
11
|
+
this.lines = new mapproxy_1.MapProxy(() => this.client.sendCommand("ll" /* ListLines */, { 'id': this.id }), (id) => new lineproxy_1.LineProxy(id, this.client));
|
|
12
|
+
this.groups = new mapproxy_1.MapProxy(() => this.client.sendCommand("lg" /* ListGroups */, { 'id': this.id }), (id) => new GroupProxy(id, this.client));
|
|
13
|
+
this.allBlocks = new mapproxy_1.MapProxy(() => this.client.sendCommand("lb" /* ListBlocks */, { 'id': this.id, 'd': true }), (id) => this.client.getBlockProxy(id));
|
|
14
|
+
this.allLines = new mapproxy_1.MapProxy(() => this.client.sendCommand("ll" /* ListLines */, { 'id': this.id, 'd': true }), (id) => new lineproxy_1.LineProxy(id, this.client));
|
|
15
|
+
this.allGroups = new mapproxy_1.MapProxy(() => this.client.sendCommand("lg" /* ListGroups */, { 'id': this.id, 'd': true }), (id) => new GroupProxy(id, this.client));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.GroupProxy = GroupProxy;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LinearOffsetType } from '../core/offsettype';
|
|
2
|
+
import { EditorClient } from '../editorclient';
|
|
3
|
+
import { Box, Point } from '../math';
|
|
4
|
+
import { ElementProxy } from './elementproxy';
|
|
5
|
+
import { MapProxy } from './mapproxy';
|
|
6
|
+
export declare class ItemProxy extends ElementProxy {
|
|
7
|
+
readonly id: string;
|
|
8
|
+
constructor(id: string, client: EditorClient);
|
|
9
|
+
readonly textAreas: MapProxy<string, string>;
|
|
10
|
+
getBoundingBox(): Box;
|
|
11
|
+
setBoundingBox(bb: Box): void;
|
|
12
|
+
getPageId(): string;
|
|
13
|
+
getLocation(): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
setLocation(location: Point): void;
|
|
18
|
+
offset(type: LinearOffsetType, offset: Point): void;
|
|
19
|
+
delete(): void;
|
|
20
|
+
getContainers(): import("./blockproxy").BlockProxy[];
|
|
21
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ItemProxy = void 0;
|
|
4
|
+
const offsettype_1 = require("../core/offsettype");
|
|
5
|
+
const elementproxy_1 = require("./elementproxy");
|
|
6
|
+
const mapproxy_1 = require("./mapproxy");
|
|
7
|
+
class ItemProxy extends elementproxy_1.ElementProxy {
|
|
8
|
+
constructor(id, client) {
|
|
9
|
+
super(id, client);
|
|
10
|
+
this.id = id;
|
|
11
|
+
this.textAreas = new mapproxy_1.MapProxy(() => this.client.sendCommand("lta" /* ListTextAreas */, this.id), (name) => this.client.sendCommand("gp" /* GetProperty */, {
|
|
12
|
+
'id': this.id,
|
|
13
|
+
'p': name,
|
|
14
|
+
}));
|
|
15
|
+
}
|
|
16
|
+
getBoundingBox() {
|
|
17
|
+
return this.properties.get('BoundingBox');
|
|
18
|
+
}
|
|
19
|
+
setBoundingBox(bb) {
|
|
20
|
+
const current = this.getBoundingBox();
|
|
21
|
+
if (current.x !== bb.x || current.y !== bb.y) {
|
|
22
|
+
this.offset(offsettype_1.OffsetType.MOVE, { x: bb.x - current.x, y: bb.y - current.y });
|
|
23
|
+
}
|
|
24
|
+
if (current.w !== bb.w || current.h !== bb.h) {
|
|
25
|
+
this.offset(offsettype_1.OffsetType.SE, {
|
|
26
|
+
x: bb.w - current.w,
|
|
27
|
+
y: bb.h - current.h,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getPageId() {
|
|
32
|
+
return this.client.sendCommand("gip" /* GetItemPageId */, this.id);
|
|
33
|
+
}
|
|
34
|
+
getLocation() {
|
|
35
|
+
const bb = this.getBoundingBox();
|
|
36
|
+
return { x: bb.x, y: bb.y };
|
|
37
|
+
}
|
|
38
|
+
setLocation(location) {
|
|
39
|
+
const current = this.getBoundingBox();
|
|
40
|
+
if (current.x !== location.x || current.y !== location.y) {
|
|
41
|
+
this.offset(offsettype_1.OffsetType.MOVE, { x: location.x - current.x, y: location.y - current.y });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
offset(type, offset) {
|
|
45
|
+
this.client.sendCommand("oi" /* OffsetItems */, { 'ids': [this.id], 't': type, 'o': offset });
|
|
46
|
+
}
|
|
47
|
+
delete() {
|
|
48
|
+
this.client.sendCommand("di" /* DeleteItem */, this.id);
|
|
49
|
+
}
|
|
50
|
+
getContainers() {
|
|
51
|
+
const containers = this.executeFormula('LABEL(CONTAINEDBY)');
|
|
52
|
+
return containers.map((id) => this.client.getBlockProxy(id));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.ItemProxy = ItemProxy;
|
|
@@ -0,0 +1,27 @@
|
|
|
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 interface LineDefinition {
|
|
25
|
+
endpoint1: EndpointDefinition;
|
|
26
|
+
endpoint2: EndpointDefinition;
|
|
27
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Point } from '../math';
|
|
2
|
+
import { BlockProxy } from './blockproxy';
|
|
3
|
+
import { ItemProxy } from './itemproxy';
|
|
4
|
+
import { EndpointDefinition } from './linedefinition';
|
|
5
|
+
export declare class LineProxy extends ItemProxy {
|
|
6
|
+
private getConnection;
|
|
7
|
+
private isBlockEndpointDefinition;
|
|
8
|
+
private isLineEndpointDefinition;
|
|
9
|
+
private parseLineEndpointDefinition;
|
|
10
|
+
private serializeLineEndpointDefinition;
|
|
11
|
+
getEndpoint1(): EndpointDefinition & {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
getEndpoint2(): EndpointDefinition & {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
setEndpoint1(endpoint: EndpointDefinition): void;
|
|
20
|
+
setEndpoint2(endpoint: EndpointDefinition): void;
|
|
21
|
+
getUpstreamConnection(): void | BlockProxy | LineProxy | undefined;
|
|
22
|
+
getDownstreamConnection(): void | BlockProxy | LineProxy | undefined;
|
|
23
|
+
getConnectedLines(): LineProxy[];
|
|
24
|
+
getRelativePosition(relative: number): Point;
|
|
25
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LineProxy = void 0;
|
|
4
|
+
const blockproxy_1 = require("./blockproxy");
|
|
5
|
+
const itemproxy_1 = require("./itemproxy");
|
|
6
|
+
class LineProxy extends itemproxy_1.ItemProxy {
|
|
7
|
+
getConnection(ep) {
|
|
8
|
+
let proxy;
|
|
9
|
+
if (ep['Block']) {
|
|
10
|
+
proxy = this.client.getBlockProxy(ep['Block']);
|
|
11
|
+
}
|
|
12
|
+
if (ep['Line']) {
|
|
13
|
+
proxy = this.client.getLineProxy(ep['Line']);
|
|
14
|
+
}
|
|
15
|
+
if (proxy && !proxy.exists()) {
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return proxy;
|
|
19
|
+
}
|
|
20
|
+
isBlockEndpointDefinition(ep) {
|
|
21
|
+
return ep.connection instanceof blockproxy_1.BlockProxy;
|
|
22
|
+
}
|
|
23
|
+
isLineEndpointDefinition(ep) {
|
|
24
|
+
return ep.connection instanceof LineProxy;
|
|
25
|
+
}
|
|
26
|
+
parseLineEndpointDefinition(raw) {
|
|
27
|
+
const connection = this.getConnection(raw);
|
|
28
|
+
if (connection instanceof LineProxy) {
|
|
29
|
+
return {
|
|
30
|
+
connection,
|
|
31
|
+
style: raw['Style'],
|
|
32
|
+
position: raw['Position'],
|
|
33
|
+
x: raw['x'],
|
|
34
|
+
y: raw['y'],
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
else if (connection) {
|
|
38
|
+
return {
|
|
39
|
+
connection,
|
|
40
|
+
style: raw['Style'],
|
|
41
|
+
linkX: raw['LinkX'],
|
|
42
|
+
linkY: raw['LinkY'],
|
|
43
|
+
inside: raw['Inside'],
|
|
44
|
+
autoLink: raw['AutoLink'],
|
|
45
|
+
padding: raw['Padding'],
|
|
46
|
+
x: raw['x'],
|
|
47
|
+
y: raw['y'],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return {
|
|
52
|
+
style: raw['Style'],
|
|
53
|
+
x: raw['x'],
|
|
54
|
+
y: raw['y'],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
serializeLineEndpointDefinition(ep) {
|
|
59
|
+
if (this.isBlockEndpointDefinition(ep)) {
|
|
60
|
+
const bb = ep.connection.getBoundingBox();
|
|
61
|
+
return {
|
|
62
|
+
'Style': ep.style,
|
|
63
|
+
'x': bb.x + bb.w * ep.linkX,
|
|
64
|
+
'y': bb.y + bb.h * ep.linkY,
|
|
65
|
+
'Block': ep.connection.id,
|
|
66
|
+
'LinkX': ep.linkX,
|
|
67
|
+
'LinkY': ep.linkY,
|
|
68
|
+
'Inside': ep.inside,
|
|
69
|
+
'AutoLink': ep.autoLink,
|
|
70
|
+
'Padding': ep.padding,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else if (this.isLineEndpointDefinition(ep)) {
|
|
74
|
+
return Object.assign({ 'Style': ep.style, 'Line': ep.connection.id, 'LineP': ep.position }, ep.connection.getRelativePosition(ep.position));
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return {
|
|
78
|
+
'Style': ep.style,
|
|
79
|
+
'x': ep.x,
|
|
80
|
+
'y': ep.y,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
getEndpoint1() {
|
|
85
|
+
return this.parseLineEndpointDefinition(this.properties.get('Endpoint1'));
|
|
86
|
+
}
|
|
87
|
+
getEndpoint2() {
|
|
88
|
+
return this.parseLineEndpointDefinition(this.properties.get('Endpoint2'));
|
|
89
|
+
}
|
|
90
|
+
setEndpoint1(endpoint) {
|
|
91
|
+
this.properties.set('Endpoint1', this.serializeLineEndpointDefinition(endpoint));
|
|
92
|
+
}
|
|
93
|
+
setEndpoint2(endpoint) {
|
|
94
|
+
this.properties.set('Endpoint2', this.serializeLineEndpointDefinition(endpoint));
|
|
95
|
+
}
|
|
96
|
+
getUpstreamConnection() {
|
|
97
|
+
return this.getEndpoint1().connection;
|
|
98
|
+
}
|
|
99
|
+
getDownstreamConnection() {
|
|
100
|
+
return this.getEndpoint2().connection;
|
|
101
|
+
}
|
|
102
|
+
getConnectedLines() {
|
|
103
|
+
const ids = this.client.sendCommand("gcl" /* GetConnectedLines */, this.id);
|
|
104
|
+
return ids.map((id) => this.client.getLineProxy(id));
|
|
105
|
+
}
|
|
106
|
+
getRelativePosition(relative) {
|
|
107
|
+
return this.client.sendCommand("grlp" /* GetRelativeLinePosition */, { 'id': this.id, 'p': relative });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
exports.LineProxy = LineProxy;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare class MapProxy<KEY, VALUE> {
|
|
2
|
+
private readonly getKeys;
|
|
3
|
+
private readonly getItem;
|
|
4
|
+
constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE);
|
|
5
|
+
[Symbol.iterator](): Iterator<[KEY, VALUE]>;
|
|
6
|
+
values(): Iterator<VALUE>;
|
|
7
|
+
keys(): KEY[];
|
|
8
|
+
get(key: KEY): VALUE;
|
|
9
|
+
first(): VALUE | undefined;
|
|
10
|
+
}
|
|
11
|
+
export declare class WriteableMapProxy<KEY, VALUE> extends MapProxy<KEY, VALUE> {
|
|
12
|
+
private readonly setter;
|
|
13
|
+
constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE, setter: (key: KEY, val: VALUE) => void);
|
|
14
|
+
set(key: KEY, value: VALUE): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteableMapProxy = exports.MapProxy = void 0;
|
|
4
|
+
class MapProxy {
|
|
5
|
+
constructor(getKeys, getItem) {
|
|
6
|
+
this.getKeys = getKeys;
|
|
7
|
+
this.getItem = getItem;
|
|
8
|
+
}
|
|
9
|
+
*[Symbol.iterator]() {
|
|
10
|
+
for (const key of this.keys()) {
|
|
11
|
+
const value = this.get(key);
|
|
12
|
+
if (value !== undefined) {
|
|
13
|
+
yield [key, value];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
*values() {
|
|
18
|
+
for (const key of this.keys()) {
|
|
19
|
+
const value = this.get(key);
|
|
20
|
+
if (value !== undefined) {
|
|
21
|
+
yield value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
keys() {
|
|
26
|
+
return this.getKeys();
|
|
27
|
+
}
|
|
28
|
+
get(key) {
|
|
29
|
+
return this.getItem(key);
|
|
30
|
+
}
|
|
31
|
+
first() {
|
|
32
|
+
const keys = this.keys();
|
|
33
|
+
if (keys.length == 0) {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return this.get(keys[0]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.MapProxy = MapProxy;
|
|
40
|
+
class WriteableMapProxy extends MapProxy {
|
|
41
|
+
constructor(getKeys, getItem, setter) {
|
|
42
|
+
super(getKeys, getItem);
|
|
43
|
+
this.setter = setter;
|
|
44
|
+
}
|
|
45
|
+
set(key, value) {
|
|
46
|
+
this.setter(key, value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.WriteableMapProxy = WriteableMapProxy;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { EditorClient } from '../editorclient';
|
|
2
|
+
import { BlockDefinition } from './blockdefinition';
|
|
3
|
+
import { BlockProxy } from './blockproxy';
|
|
4
|
+
import { ElementProxy } from './elementproxy';
|
|
5
|
+
import { GroupProxy } from './groupproxy';
|
|
6
|
+
import { LineDefinition } from './linedefinition';
|
|
7
|
+
import { LineProxy } from './lineproxy';
|
|
8
|
+
import { MapProxy } from './mapproxy';
|
|
9
|
+
export declare class PageProxy extends ElementProxy {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
constructor(id: string, client: EditorClient);
|
|
12
|
+
readonly blocks: MapProxy<string, BlockProxy>;
|
|
13
|
+
readonly lines: MapProxy<string, LineProxy>;
|
|
14
|
+
readonly groups: MapProxy<string, GroupProxy>;
|
|
15
|
+
readonly allBlocks: MapProxy<string, BlockProxy>;
|
|
16
|
+
readonly allLines: MapProxy<string, LineProxy>;
|
|
17
|
+
readonly allGroups: MapProxy<string, GroupProxy>;
|
|
18
|
+
addBlock(def: BlockDefinition): BlockProxy;
|
|
19
|
+
addLine(def: LineDefinition): LineProxy;
|
|
20
|
+
setTitle(title: string): void;
|
|
21
|
+
getTitle(): string;
|
|
22
|
+
delete(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PageProxy = void 0;
|
|
4
|
+
const elementproxy_1 = require("./elementproxy");
|
|
5
|
+
const groupproxy_1 = require("./groupproxy");
|
|
6
|
+
const lineproxy_1 = require("./lineproxy");
|
|
7
|
+
const mapproxy_1 = require("./mapproxy");
|
|
8
|
+
class PageProxy extends elementproxy_1.ElementProxy {
|
|
9
|
+
constructor(id, client) {
|
|
10
|
+
super(id, client);
|
|
11
|
+
this.id = id;
|
|
12
|
+
this.blocks = new mapproxy_1.MapProxy(() => this.client.sendCommand("lb" /* ListBlocks */, { id: this.id }), (id) => this.client.getBlockProxy(id));
|
|
13
|
+
this.lines = new mapproxy_1.MapProxy(() => this.client.sendCommand("ll" /* ListLines */, { id: this.id }), (id) => new lineproxy_1.LineProxy(id, this.client));
|
|
14
|
+
this.groups = new mapproxy_1.MapProxy(() => this.client.sendCommand("lg" /* ListGroups */, { id: this.id }), (id) => new groupproxy_1.GroupProxy(id, this.client));
|
|
15
|
+
this.allBlocks = new mapproxy_1.MapProxy(() => this.client.sendCommand("lb" /* ListBlocks */, { id: this.id, d: true }), (id) => this.client.getBlockProxy(id));
|
|
16
|
+
this.allLines = new mapproxy_1.MapProxy(() => this.client.sendCommand("ll" /* ListLines */, { id: this.id, d: true }), (id) => new lineproxy_1.LineProxy(id, this.client));
|
|
17
|
+
this.allGroups = new mapproxy_1.MapProxy(() => this.client.sendCommand("lg" /* ListGroups */, { id: this.id, d: true }), (id) => new groupproxy_1.GroupProxy(id, this.client));
|
|
18
|
+
}
|
|
19
|
+
addBlock(def) {
|
|
20
|
+
const id = this.client.sendCommand("cb" /* CreateBlock */, {
|
|
21
|
+
'p': this.id,
|
|
22
|
+
'c': def.className,
|
|
23
|
+
});
|
|
24
|
+
const block = this.client.getBlockProxy(id);
|
|
25
|
+
block.setBoundingBox(def.boundingBox);
|
|
26
|
+
return block;
|
|
27
|
+
}
|
|
28
|
+
addLine(def) {
|
|
29
|
+
const id = this.client.sendCommand("cl" /* CreateLine */, {
|
|
30
|
+
'p': this.id,
|
|
31
|
+
});
|
|
32
|
+
const line = new lineproxy_1.LineProxy(id, this.client);
|
|
33
|
+
line.setEndpoint1(def.endpoint1);
|
|
34
|
+
line.setEndpoint2(def.endpoint2);
|
|
35
|
+
return line;
|
|
36
|
+
}
|
|
37
|
+
setTitle(title) {
|
|
38
|
+
this.properties.set('Title', title);
|
|
39
|
+
}
|
|
40
|
+
getTitle() {
|
|
41
|
+
return this.properties.get('Title');
|
|
42
|
+
}
|
|
43
|
+
delete() {
|
|
44
|
+
this.client.sendCommand("dp" /* DeletePage */, this.id);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.PageProxy = PageProxy;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SerializedDataError } from '../core/serializeddataerror';
|
|
2
|
+
import { SerializedFieldType } from '../core/serializedfields';
|
|
3
|
+
import { DataError } from '../data/dataerror';
|
|
4
|
+
import { EditorClient } from '../editorclient';
|
|
5
|
+
import { WriteableMapProxy } from './mapproxy';
|
|
6
|
+
export declare class ShapeDataProxy extends WriteableMapProxy<string, SerializedFieldType | SerializedDataError> {
|
|
7
|
+
readonly id: string | undefined;
|
|
8
|
+
protected readonly client: EditorClient;
|
|
9
|
+
constructor(id: string | undefined, client: EditorClient);
|
|
10
|
+
delete(key: string): void;
|
|
11
|
+
static parseData(raw: SerializedFieldType | SerializedDataError): SerializedFieldType | DataError;
|
|
12
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShapeDataProxy = void 0;
|
|
4
|
+
const serializeddataerror_1 = require("../core/serializeddataerror");
|
|
5
|
+
const shapedatainheritance_1 = require("../core/shapedatainheritance");
|
|
6
|
+
const dataerror_1 = require("../data/dataerror");
|
|
7
|
+
const mapproxy_1 = require("./mapproxy");
|
|
8
|
+
class ShapeDataProxy extends mapproxy_1.WriteableMapProxy {
|
|
9
|
+
constructor(id, client) {
|
|
10
|
+
super(() => this.client.sendCommand("lsd" /* ListShapeData */, { 'id': this.id }), (name) => ShapeDataProxy.parseData(this.client.sendCommand("gsd" /* GetShapeData */, {
|
|
11
|
+
'id': this.id,
|
|
12
|
+
'n': name,
|
|
13
|
+
})), (name, value) => {
|
|
14
|
+
if ((0, serializeddataerror_1.isSerializedDataError)(value)) {
|
|
15
|
+
throw new Error('Cannot store an error value');
|
|
16
|
+
}
|
|
17
|
+
if (this.keys().includes(name)) {
|
|
18
|
+
this.client.sendCommand("ssd" /* SetShapeData */, { 'id': this.id, 'n': name, 'v': value });
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
this.client.sendCommand("asd" /* AddShapeData */, {
|
|
22
|
+
'id': this.id,
|
|
23
|
+
'i': shapedatainheritance_1.ShapeDataInheritance.NONE,
|
|
24
|
+
'n': name,
|
|
25
|
+
'v': value,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
this.id = id;
|
|
30
|
+
this.client = client;
|
|
31
|
+
}
|
|
32
|
+
delete(key) {
|
|
33
|
+
if (this.keys().includes(key)) {
|
|
34
|
+
this.client.sendCommand("dsd" /* DeleteShapeData */, { 'id': this.id, 'n': key });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
static parseData(raw) {
|
|
38
|
+
if ((0, serializeddataerror_1.isSerializedDataError)(raw)) {
|
|
39
|
+
return new dataerror_1.DataError(raw['error'], raw['type']);
|
|
40
|
+
}
|
|
41
|
+
//TODO, eventually: parse these
|
|
42
|
+
return raw;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ShapeDataProxy = ShapeDataProxy;
|