lucid-extension-sdk 0.0.216 → 0.0.218

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/commandtypes.d.ts CHANGED
@@ -28,6 +28,8 @@ export declare const enum CommandName {
28
28
  AddMenuItem = "ami",
29
29
  AddShapeData = "asd",
30
30
  AddSpreadsheetIntegration = "asi",
31
+ AddTableColumn = "atc",
32
+ AddTableRow = "atr",
31
33
  Alert = "a",
32
34
  AnimateViewport = "av",
33
35
  AwaitDataSourceImport = "adi",
@@ -50,6 +52,8 @@ export declare const enum CommandName {
50
52
  DeleteItem = "di",
51
53
  DeletePage = "dp",
52
54
  DeleteShapeData = "dsd",
55
+ DeleteTableColumn = "dtc",
56
+ DeleteTableRow = "dtr",
53
57
  Download = "d",
54
58
  DragPointerMove = "dpm",
55
59
  DragPointerUp = "dpu",
@@ -174,6 +178,14 @@ export type CommandArgs = {
174
178
  query: AddSpreadsheetIntegrationQuery;
175
179
  result: AddSpreadsheetIntegrationResult;
176
180
  };
181
+ [CommandName.AddTableColumn]: {
182
+ query: AddTableColumnQuery;
183
+ result: AddTableColumnResult;
184
+ };
185
+ [CommandName.AddTableRow]: {
186
+ query: AddTableRowQuery;
187
+ result: AddTableRowResult;
188
+ };
177
189
  [CommandName.Alert]: {
178
190
  query: AlertQuery;
179
191
  result: AlertResult;
@@ -262,6 +274,14 @@ export type CommandArgs = {
262
274
  query: DeleteShapeDataQuery;
263
275
  result: DeleteShapeDataResult;
264
276
  };
277
+ [CommandName.DeleteTableColumn]: {
278
+ query: DeleteTableColumnQuery;
279
+ result: DeleteTableColumnResult;
280
+ };
281
+ [CommandName.DeleteTableRow]: {
282
+ query: DeleteTableRowQuery;
283
+ result: DeleteTableRowResult;
284
+ };
265
285
  [CommandName.Download]: {
266
286
  query: DownloadQuery;
267
287
  result: DownloadResult;
@@ -747,6 +767,30 @@ export type AddSpreadsheetIntegrationQuery = {
747
767
  };
748
768
  /** @ignore until spreadsheet integration is ready for launch (CHART-51946) */
749
769
  export type AddSpreadsheetIntegrationResult = undefined;
770
+ export type AddTableColumnQuery = {
771
+ /** ID of the table to add this column to */
772
+ 'id': string;
773
+ /** Row of the reference cell that the column should be added next to */
774
+ 'r': number;
775
+ /** Column of the reference cell that the column should be added next to */
776
+ 'c': number;
777
+ /** True if the column should be added before the reference cell */
778
+ 'b': boolean;
779
+ };
780
+ /** The index of the newly created column */
781
+ export type AddTableColumnResult = number;
782
+ export type AddTableRowQuery = {
783
+ /** ID of the table to add this row to */
784
+ 'id': string;
785
+ /** Row of the reference cell that the row should be added next to */
786
+ 'r': number;
787
+ /** Column of the reference cell that the row should be added next to */
788
+ 'c': number;
789
+ /** True if the row should be added before the reference cell */
790
+ 'b': boolean;
791
+ };
792
+ /** The index of the newly created row */
793
+ export type AddTableRowResult = number;
750
794
  export type AlertQuery = {
751
795
  /** Title; defaults to extension title */
752
796
  't'?: string | undefined;
@@ -926,6 +970,20 @@ export type DeleteShapeDataQuery = {
926
970
  'n': string;
927
971
  };
928
972
  export type DeleteShapeDataResult = undefined;
973
+ export type DeleteTableColumnQuery = {
974
+ /** ID of the table to delete this column from */
975
+ 'id': string;
976
+ /** Index of the column to delete */
977
+ 'i': number;
978
+ };
979
+ export type DeleteTableColumnResult = void;
980
+ export type DeleteTableRowQuery = {
981
+ /** ID of the table to delete this row from */
982
+ 'id': string;
983
+ /** Index of the row to delete */
984
+ 'i': number;
985
+ };
986
+ export type DeleteTableRowResult = void;
929
987
  export type DownloadQuery = {
930
988
  /** Filename of the download */
931
989
  'f': string;
@@ -1038,11 +1096,19 @@ export type GetItemsAtQuery = {
1038
1096
  };
1039
1097
  /** IDs of the items found */
1040
1098
  export type GetItemsAtResult = string[];
1099
+ export declare enum GetLLMContextType {
1100
+ /** Get context in a format for LLMs where relationships among connected and contained items is preserved */
1101
+ Relational = 1,
1102
+ /** Get context containing only plain text displayed on the given items, more suitable for embeddings */
1103
+ PlainText = 2
1104
+ }
1041
1105
  export type GetLLMContextFromItemsQuery = {
1042
1106
  /** Page ID to find closely-related items */
1043
1107
  'p': string;
1044
1108
  /** List of item IDs to return LLM-readable context for */
1045
1109
  'i': string[];
1110
+ /** Type of context to get */
1111
+ 't'?: GetLLMContextType | undefined;
1046
1112
  };
1047
1113
  export type GetLLMContextFromItemsResult = {
1048
1114
  /**
package/commandtypes.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZOrderOperation = exports.isRawSendXHRResponse = exports.GetItemsAtSearchType = exports.HashAlgorithmEnum = exports.commandTitles = void 0;
3
+ exports.ZOrderOperation = exports.isRawSendXHRResponse = exports.GetLLMContextType = exports.GetItemsAtSearchType = exports.HashAlgorithmEnum = exports.commandTitles = void 0;
4
4
  const checks_1 = require("./core/checks");
5
5
  /** @ignore */
6
6
  exports.commandTitles = new Map([
@@ -9,6 +9,8 @@ exports.commandTitles = new Map([
9
9
  ["ami" /* CommandName.AddMenuItem */, 'AddMenuItem'],
10
10
  ["asd" /* CommandName.AddShapeData */, 'AddShapeData'],
11
11
  ["asi" /* CommandName.AddSpreadsheetIntegration */, 'AddSpreadsheetIntegration'],
12
+ ["atc" /* CommandName.AddTableColumn */, 'AddTableColumn'],
13
+ ["atr" /* CommandName.AddTableRow */, 'AddTableRow'],
12
14
  ["a" /* CommandName.Alert */, 'Alert'],
13
15
  ["av" /* CommandName.AnimateViewport */, 'AnimateViewport'],
14
16
  ["adi" /* CommandName.AwaitDataSourceImport */, 'AwaitDataSourceImport'],
@@ -28,6 +30,8 @@ exports.commandTitles = new Map([
28
30
  ["di" /* CommandName.DeleteItem */, 'DeleteItem'],
29
31
  ["dp" /* CommandName.DeletePage */, 'DeletePage'],
30
32
  ["dsd" /* CommandName.DeleteShapeData */, 'DeleteShapeData'],
33
+ ["dtc" /* CommandName.DeleteTableColumn */, 'DeleteTableColumn'],
34
+ ["dtr" /* CommandName.DeleteTableRow */, 'DeleteTableRow'],
31
35
  ["d" /* CommandName.Download */, 'Download'],
32
36
  ["dpm" /* CommandName.DragPointerMove */, 'DragPointerMove'],
33
37
  ["dpu" /* CommandName.DragPointerUp */, 'DragPointerUp'],
@@ -131,6 +135,13 @@ var GetItemsAtSearchType;
131
135
  GetItemsAtSearchType[GetItemsAtSearchType["Overlapping"] = 1] = "Overlapping";
132
136
  GetItemsAtSearchType[GetItemsAtSearchType["Contained"] = 2] = "Contained";
133
137
  })(GetItemsAtSearchType = exports.GetItemsAtSearchType || (exports.GetItemsAtSearchType = {}));
138
+ var GetLLMContextType;
139
+ (function (GetLLMContextType) {
140
+ /** Get context in a format for LLMs where relationships among connected and contained items is preserved */
141
+ GetLLMContextType[GetLLMContextType["Relational"] = 1] = "Relational";
142
+ /** Get context containing only plain text displayed on the given items, more suitable for embeddings */
143
+ GetLLMContextType[GetLLMContextType["PlainText"] = 2] = "PlainText";
144
+ })(GetLLMContextType = exports.GetLLMContextType || (exports.GetLLMContextType = {}));
134
145
  function isRawSendXHRResponse(val) {
135
146
  return (0, checks_1.isString)(val['url']) && (0, checks_1.isString)(val['t']) && (0, checks_1.isNumber)(val['s']) && (0, checks_1.isObject)(val['h']);
136
147
  }
@@ -53,8 +53,37 @@ export declare class TableRowProxy {
53
53
  getCells(): TableCellProxy[];
54
54
  getHeight(): number;
55
55
  }
56
+ export declare class TableColumnProxy {
57
+ readonly table: TableBlockProxy;
58
+ readonly col: number;
59
+ constructor(table: TableBlockProxy, col: number);
60
+ getCells(): TableCellProxy[];
61
+ getWidth(): number;
62
+ }
56
63
  export declare class TableBlockProxy extends BlockProxy {
57
64
  static classNameRegex: RegExp;
65
+ /**
66
+ *
67
+ * @param referenceCell The cell to add the new column before or after.
68
+ * @param before If true, the new column will be added before the reference cell, otherwise it will be added after.
69
+ * @returns The TableColumnProxy for the newly added column.
70
+ */
71
+ addColumn(referenceCell: TableCellProxy, before?: boolean): TableColumnProxy;
72
+ /**
73
+ *
74
+ * @param referenceCell The cell to add the new row before or after.
75
+ * @param before If true, the new row will be added before the reference cell, otherwise it will be added after.
76
+ * @returns The TableRowProxy for the newly added row.
77
+ */
78
+ addRow(referenceCell: TableCellProxy, before?: boolean): TableRowProxy;
79
+ /**
80
+ * @param column The index of the column to delete.
81
+ */
82
+ deleteColumn(column: number): void;
83
+ /**
84
+ * @param row The index of the row to delete.
85
+ */
86
+ deleteRow(row: number): void;
58
87
  getRowCount(): number;
59
88
  getColumnCount(): number;
60
89
  getRows(): TableRowProxy[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TableBlockProxy = exports.TableRowProxy = exports.TableCellProxy = void 0;
3
+ exports.TableBlockProxy = exports.TableColumnProxy = exports.TableRowProxy = exports.TableCellProxy = void 0;
4
4
  const fillcolor_1 = require("../../core/properties/fillcolor");
5
5
  const blockproxy_1 = require("../blockproxy");
6
6
  class TableCellProxy {
@@ -95,7 +95,63 @@ class TableRowProxy {
95
95
  }
96
96
  }
97
97
  exports.TableRowProxy = TableRowProxy;
98
+ class TableColumnProxy {
99
+ constructor(table, col) {
100
+ this.table = table;
101
+ this.col = col;
102
+ }
103
+ getCells() {
104
+ return this.table.getRowHeights().map((_, index) => new TableCellProxy(this.table, this.col, index));
105
+ }
106
+ getWidth() {
107
+ var _a;
108
+ return (_a = this.table.getColumnWidths()[this.col]) !== null && _a !== void 0 ? _a : 1;
109
+ }
110
+ }
111
+ exports.TableColumnProxy = TableColumnProxy;
98
112
  class TableBlockProxy extends blockproxy_1.BlockProxy {
113
+ /**
114
+ *
115
+ * @param referenceCell The cell to add the new column before or after.
116
+ * @param before If true, the new column will be added before the reference cell, otherwise it will be added after.
117
+ * @returns The TableColumnProxy for the newly added column.
118
+ */
119
+ addColumn(referenceCell, before = false) {
120
+ const col = this.client.sendCommand("atc" /* CommandName.AddTableColumn */, {
121
+ 'id': this.id,
122
+ 'r': referenceCell.row,
123
+ 'c': referenceCell.column,
124
+ 'b': before,
125
+ });
126
+ return new TableColumnProxy(this, col);
127
+ }
128
+ /**
129
+ *
130
+ * @param referenceCell The cell to add the new row before or after.
131
+ * @param before If true, the new row will be added before the reference cell, otherwise it will be added after.
132
+ * @returns The TableRowProxy for the newly added row.
133
+ */
134
+ addRow(referenceCell, before = false) {
135
+ const row = this.client.sendCommand("atr" /* CommandName.AddTableRow */, {
136
+ 'id': this.id,
137
+ 'r': referenceCell.row,
138
+ 'c': referenceCell.column,
139
+ 'b': before,
140
+ });
141
+ return new TableRowProxy(this, row);
142
+ }
143
+ /**
144
+ * @param column The index of the column to delete.
145
+ */
146
+ deleteColumn(column) {
147
+ return this.client.sendCommand("dtc" /* CommandName.DeleteTableColumn */, { 'id': this.id, 'i': column });
148
+ }
149
+ /**
150
+ * @param row The index of the row to delete.
151
+ */
152
+ deleteRow(row) {
153
+ return this.client.sendCommand("dtr" /* CommandName.DeleteTableRow */, { 'id': this.id, 'i': row });
154
+ }
99
155
  getRowCount() {
100
156
  return this.getRowHeights().length;
101
157
  }
@@ -19,6 +19,10 @@ export declare class BlockProxy extends ItemProxy {
19
19
  * @returns The amount this block is rotated around its own center, in radians.
20
20
  */
21
21
  getRotation(): number;
22
+ /**
23
+ * @returns An axis-aligned bounding box containing this full item after any rotation it might have
24
+ */
25
+ getRotatedBoundingBox(): import("../math").Box;
22
26
  /**
23
27
  * @param radians Angle the block should be rotated
24
28
  */
@@ -5,6 +5,7 @@ const badgeposition_1 = require("../core/properties/datagraphic/badgeposition");
5
5
  const staticdatagraphicsettings_1 = require("../core/properties/datagraphic/staticdatagraphicsettings");
6
6
  const fillcolor_1 = require("../core/properties/fillcolor");
7
7
  const shadow_1 = require("../core/properties/shadow");
8
+ const math_1 = require("../math");
8
9
  const itemproxy_1 = require("./itemproxy");
9
10
  /**
10
11
  * A block is a single shape on the document. A BlockProxy provides an interface to
@@ -26,6 +27,12 @@ class BlockProxy extends itemproxy_1.ItemProxy {
26
27
  getRotation() {
27
28
  return this.properties.get('Rotation');
28
29
  }
30
+ /**
31
+ * @returns An axis-aligned bounding box containing this full item after any rotation it might have
32
+ */
33
+ getRotatedBoundingBox() {
34
+ return (0, math_1.rotatedBoundingBox)(this.getBoundingBox(), this.getRotation());
35
+ }
29
36
  /**
30
37
  * @param radians Angle the block should be rotated
31
38
  */
@@ -1,4 +1,4 @@
1
- import { GetItemsAtSearchType } from '../commandtypes';
1
+ import { GetItemsAtSearchType, GetLLMContextType } from '../commandtypes';
2
2
  import { EditorClient } from '../editorclient';
3
3
  import { Box } from '../math';
4
4
  import { BlockDefinition } from './blockdefinition';
@@ -114,7 +114,7 @@ export declare class PageProxy extends ElementProxy {
114
114
  * necessary, in a format that is easily understandable by LLMs like ChatGPT. Also a map of IDs, from the shortened
115
115
  * IDs provided for the items in the context to the actual Lucid item IDs.
116
116
  */
117
- getLLMContextForItems(items: ItemProxy[]): {
117
+ getLLMContextForItems(items: ItemProxy[], contextType?: GetLLMContextType): {
118
118
  prompt: string;
119
119
  idToLucidId: Map<string, string>;
120
120
  };
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PageProxy = void 0;
4
+ const commandtypes_1 = require("../commandtypes");
4
5
  const ruleproxy_1 = require("./documentelement/ruleproxy");
5
6
  const elementproxy_1 = require("./elementproxy");
6
7
  const groupproxy_1 = require("./groupproxy");
@@ -180,12 +181,13 @@ class PageProxy extends elementproxy_1.ElementProxy {
180
181
  * necessary, in a format that is easily understandable by LLMs like ChatGPT. Also a map of IDs, from the shortened
181
182
  * IDs provided for the items in the context to the actual Lucid item IDs.
182
183
  */
183
- getLLMContextForItems(items) {
184
+ getLLMContextForItems(items, contextType = commandtypes_1.GetLLMContextType.Relational) {
184
185
  //We don't check that the items are on this page here; that is done in the implementation
185
186
  //of the API command. It would be a lot of extra API calls for no benefit.
186
187
  const result = this.client.sendCommand("llm" /* CommandName.GetLLMContextFromItems */, {
187
188
  'p': this.id,
188
189
  'i': items.map((item) => item.id),
190
+ 't': contextType,
189
191
  });
190
192
  return {
191
193
  prompt: result['p'],
package/math.d.ts CHANGED
@@ -31,3 +31,16 @@ export declare function percentBoxesOverlap(a: Box, b: Box): number;
31
31
  * @return a clipped to b
32
32
  */
33
33
  export declare function clip(a: Box, b: Box): Box;
34
+ export declare function boxCenter(b: Box): {
35
+ x: number;
36
+ y: number;
37
+ };
38
+ /**
39
+ * Returns the bounding box that would surround the given
40
+ * box when rotated the given amount.
41
+ */
42
+ export declare function rotatedBoundingBox(b: Box, angle: number, center?: Point): Box;
43
+ export declare function rotateBox(b: Box, angle: number, center?: Point): [Point, Point, Point, Point];
44
+ export declare function boxFrom4Points(a: Point, b: Point, c: Point, d: Point): Box;
45
+ export declare function toCornersAsArray(box: Box): [Point, Point, Point, Point];
46
+ export declare function rotateAroundFn(anchor: Point, angle: number): (p1: Point) => Point;
package/math.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clip = exports.percentBoxesOverlap = exports.boxesOverlap = exports.isBoxWithin = exports.padBox = exports.combinedBoundingBox = void 0;
3
+ exports.rotateAroundFn = exports.toCornersAsArray = exports.boxFrom4Points = exports.rotateBox = exports.rotatedBoundingBox = exports.boxCenter = exports.clip = exports.percentBoxesOverlap = exports.boxesOverlap = exports.isBoxWithin = exports.padBox = exports.combinedBoundingBox = void 0;
4
4
  function combinedBoundingBox(boxes) {
5
5
  if (boxes.length == 0) {
6
6
  return undefined;
@@ -64,3 +64,57 @@ function clip(a, b) {
64
64
  return { x, y, w, h };
65
65
  }
66
66
  exports.clip = clip;
67
+ function boxCenter(b) {
68
+ return { x: b.x + b.w / 2, y: b.y + b.h / 2 };
69
+ }
70
+ exports.boxCenter = boxCenter;
71
+ /**
72
+ * Returns the bounding box that would surround the given
73
+ * box when rotated the given amount.
74
+ */
75
+ function rotatedBoundingBox(b, angle, center) {
76
+ if (!angle) {
77
+ return b;
78
+ }
79
+ center = center || boxCenter(b);
80
+ return boxFrom4Points.apply(null, rotateBox(b, angle, center));
81
+ }
82
+ exports.rotatedBoundingBox = rotatedBoundingBox;
83
+ function rotateBox(b, angle, center) {
84
+ const ret = toCornersAsArray(b);
85
+ center = center || boxCenter(b);
86
+ if (angle != 0) {
87
+ return ret.map(rotateAroundFn(center, angle));
88
+ }
89
+ return ret;
90
+ }
91
+ exports.rotateBox = rotateBox;
92
+ function boxFrom4Points(a, b, c, d) {
93
+ const xMin = Math.min(a.x, b.x, c.x, d.x);
94
+ const xMax = Math.max(a.x, b.x, c.x, d.x);
95
+ const yMin = Math.min(a.y, b.y, c.y, d.y);
96
+ const yMax = Math.max(a.y, b.y, c.y, d.y);
97
+ return { x: xMin, y: yMin, w: xMax - xMin, h: yMax - yMin };
98
+ }
99
+ exports.boxFrom4Points = boxFrom4Points;
100
+ function toCornersAsArray(box) {
101
+ return [
102
+ { x: box.x, y: box.y },
103
+ { x: box.x + box.w, y: box.y },
104
+ { x: box.x + box.w, y: box.y + box.h },
105
+ { x: box.x, y: box.y + box.h },
106
+ ];
107
+ }
108
+ exports.toCornersAsArray = toCornersAsArray;
109
+ function rotateAroundFn(anchor, angle) {
110
+ const cos = Math.cos(angle);
111
+ const sin = Math.sin(angle);
112
+ return (p) => {
113
+ const anchorX = anchor.x;
114
+ const anchorY = anchor.y;
115
+ const x = p.x - anchorX;
116
+ const y = p.y - anchorY;
117
+ return { x: x * cos - y * sin + anchorX, y: y * cos + x * sin + anchorY };
118
+ };
119
+ }
120
+ exports.rotateAroundFn = rotateAroundFn;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.216",
3
+ "version": "0.0.218",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",