lucid-extension-sdk 0.0.224 → 0.0.226

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
@@ -1223,6 +1223,8 @@ export type HookSelectionResult = undefined;
1223
1223
  export type HookTextEditQuery = {
1224
1224
  /** Name of the action for receiving these events */
1225
1225
  'n': string;
1226
+ /** Whether to trigger the text hook callback eagerly during text edit */
1227
+ 'e'?: boolean | undefined;
1226
1228
  };
1227
1229
  export type HookTextEditResult = undefined;
1228
1230
  /** Name of the card integration registered by this extension to show the import dialog for */
@@ -1424,6 +1426,12 @@ export type SendXHRQuery = {
1424
1426
  * - If 'binary', the response body will be returned as a Uint8Array.
1425
1427
  */
1426
1428
  'f'?: SendXHRResponseFormat | undefined;
1429
+ /**
1430
+ * If set, a callback to call with chunks of the response as they arrive.
1431
+ * Only valid for utf8 (text) requests, and only called on successful responses.
1432
+ * The full final response will still be returned as normal.
1433
+ */
1434
+ 's'?: string | undefined;
1427
1435
  };
1428
1436
  export type RawSendXHRResponse = {
1429
1437
  /** URL of the response after any redirects */
package/core/xhr.d.ts CHANGED
@@ -20,6 +20,10 @@ export interface XHRRequest {
20
20
  * - If 'binary', the response body will be returned as a Uint8Array.
21
21
  */
22
22
  responseFormat?: SendXHRResponseFormat;
23
+ /**
24
+ * For utf8 responses, you can have the result streamed to you for endpoints that support it.
25
+ */
26
+ streamCallback?: (chunk: string) => void;
23
27
  }
24
28
  export interface OAuthXHRRequest extends XHRRequest {
25
29
  /**
@@ -84,6 +84,11 @@ export declare class TableBlockProxy extends BlockProxy {
84
84
  * @param row The index of the row to delete.
85
85
  */
86
86
  deleteRow(row: number): void;
87
+ /**
88
+ * @param textAreaKey The text area key of a cell in the table
89
+ * @returns The TableCellProxy represented by the text area key, or undefined if the text area key does not exist in the table.
90
+ */
91
+ getCellByTextAreaKey(textAreaKey: string): TableCellProxy | undefined;
87
92
  getRowCount(): number;
88
93
  getColumnCount(): number;
89
94
  getRows(): TableRowProxy[];
@@ -152,6 +152,19 @@ class TableBlockProxy extends blockproxy_1.BlockProxy {
152
152
  deleteRow(row) {
153
153
  return this.client.sendCommand("dtr" /* CommandName.DeleteTableRow */, { 'id': this.id, 'i': row });
154
154
  }
155
+ /**
156
+ * @param textAreaKey The text area key of a cell in the table
157
+ * @returns The TableCellProxy represented by the text area key, or undefined if the text area key does not exist in the table.
158
+ */
159
+ getCellByTextAreaKey(textAreaKey) {
160
+ const value = textAreaKey.match(/(\d+)/g);
161
+ if (value && value.length === 2) {
162
+ const row = +value[0];
163
+ const column = +value[1];
164
+ return new TableCellProxy(this, row, column);
165
+ }
166
+ return undefined;
167
+ }
155
168
  getRowCount() {
156
169
  return this.getRowHeights().length;
157
170
  }
package/editorclient.js CHANGED
@@ -182,6 +182,11 @@ class EditorClient {
182
182
  });
183
183
  }
184
184
  xhr(request) {
185
+ let streamCallback;
186
+ if (request.streamCallback) {
187
+ streamCallback = this.getUniqueActionName();
188
+ this.registerAction(streamCallback, (msg) => { var _a; return (_a = request.streamCallback) === null || _a === void 0 ? void 0 : _a.call(request, msg['d']); });
189
+ }
185
190
  const responseFormat = request.responseFormat || 'utf8';
186
191
  return this.sendCommand("xhr" /* CommandName.SendXHR */, {
187
192
  'url': request.url,
@@ -190,6 +195,7 @@ class EditorClient {
190
195
  'h': request.headers,
191
196
  'ms': request.timeoutMs,
192
197
  'f': responseFormat,
198
+ 's': streamCallback,
193
199
  })
194
200
  .then((raw) => {
195
201
  return parseRawXHRResponse(responseFormat, raw);
@@ -197,6 +203,11 @@ class EditorClient {
197
203
  .catch((error) => {
198
204
  const raw = (0, commandtypes_1.isRawSendXHRResponse)(error) ? error : undefined;
199
205
  throw parseRawXHRResponse(responseFormat, raw);
206
+ })
207
+ .finally(() => {
208
+ if (streamCallback) {
209
+ this.deleteAction(streamCallback);
210
+ }
200
211
  });
201
212
  }
202
213
  asyncOAuthXhr(providerName, request) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.224",
3
+ "version": "0.0.226",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
package/ui/viewport.d.ts CHANGED
@@ -60,21 +60,23 @@ export declare class Viewport {
60
60
  */
61
61
  focusCameraOnItems(items: ItemProxy[]): void;
62
62
  /**
63
- * If `callback` returns false, text editing is prevented.
64
- * If `callback` returns true, text editing continues as normal.
63
+ * If {@link callback} returns false, text editing is prevented.
64
+ * If {@link callback} returns true, text editing continues as normal.
65
+ *
66
+ * If {@link callback} returns a {@link TextEditCompletionCallback}(/extension-sdk/#modules_ui_viewport_texteditcompletioncallback),
67
+ * then text editing is allowed, but that completion callback is called.
65
68
  *
66
- * If `callback` returns a [TextEditCompletionCallback](/extension-sdk/#modules_ui_viewport_texteditcompletioncallback), then text editing
67
- * is allowed, but that completion callback is called
68
69
  * when the user finishes editing that text. That completion callback may return true or false to allow or deny the edit, or
69
70
  * also may return a replacement string to use instead of the text the user actually typed. If replacement text is provided,
70
71
  * it will be styled as close to the original as possible, but styles that apply to only parts of the original text will be
71
72
  * discarded.
72
73
  *
73
74
  * @param callback Called just before the user starts editing text.
75
+ * @param eager Whether to trigger the callback eagerly during text edit
74
76
  *
75
77
  * @returns A handle representing this hook, which can be passed to unhookTextEdit to remove this hook.
76
78
  */
77
- hookTextEdit(callback: (item: ItemProxy, textAreaKey: string) => boolean | TextEditCompletionCallback | Promise<boolean | TextEditCompletionCallback>): string;
79
+ hookTextEdit(callback: (item: ItemProxy, textAreaKey: string, text?: string) => boolean | TextEditCompletionCallback | Promise<boolean | TextEditCompletionCallback>, eager?: boolean): string;
78
80
  /**
79
81
  * Remove a hook set by hookTextEdit.
80
82
  *
package/ui/viewport.js CHANGED
@@ -83,26 +83,28 @@ class Viewport {
83
83
  }
84
84
  }
85
85
  /**
86
- * If `callback` returns false, text editing is prevented.
87
- * If `callback` returns true, text editing continues as normal.
86
+ * If {@link callback} returns false, text editing is prevented.
87
+ * If {@link callback} returns true, text editing continues as normal.
88
+ *
89
+ * If {@link callback} returns a {@link TextEditCompletionCallback}(/extension-sdk/#modules_ui_viewport_texteditcompletioncallback),
90
+ * then text editing is allowed, but that completion callback is called.
88
91
  *
89
- * If `callback` returns a [TextEditCompletionCallback](/extension-sdk/#modules_ui_viewport_texteditcompletioncallback), then text editing
90
- * is allowed, but that completion callback is called
91
92
  * when the user finishes editing that text. That completion callback may return true or false to allow or deny the edit, or
92
93
  * also may return a replacement string to use instead of the text the user actually typed. If replacement text is provided,
93
94
  * it will be styled as close to the original as possible, but styles that apply to only parts of the original text will be
94
95
  * discarded.
95
96
  *
96
97
  * @param callback Called just before the user starts editing text.
98
+ * @param eager Whether to trigger the callback eagerly during text edit
97
99
  *
98
100
  * @returns A handle representing this hook, which can be passed to unhookTextEdit to remove this hook.
99
101
  */
100
- hookTextEdit(callback) {
102
+ hookTextEdit(callback, eager) {
101
103
  const actionName = Viewport.nextHookName();
102
104
  this.client.registerAction(actionName, async (textHookParam) => {
103
105
  const element = this.client.getElementProxy(textHookParam['i']);
104
106
  if (element instanceof itemproxy_1.ItemProxy) {
105
- const result = await callback(element, textHookParam['t']);
107
+ const result = await callback(element, textHookParam['t'], textHookParam['v']);
106
108
  if ((0, checks_1.isBoolean)(result)) {
107
109
  return result;
108
110
  }
@@ -120,7 +122,7 @@ class Viewport {
120
122
  return true;
121
123
  }
122
124
  });
123
- this.client.sendCommand("hte" /* CommandName.HookTextEdit */, { 'n': actionName });
125
+ this.client.sendCommand("hte" /* CommandName.HookTextEdit */, { 'n': actionName, 'e': !!eager });
124
126
  return actionName;
125
127
  }
126
128
  /**