lucid-extension-sdk 0.0.213 → 0.0.215
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 +16 -0
- package/commandtypes.js +1 -0
- package/core/checks.d.ts +4 -0
- package/core/checks.js +9 -1
- package/document/itemproxy.d.ts +4 -0
- package/document/itemproxy.js +7 -1
- package/document/pageproxy.d.ts +8 -0
- package/document/pageproxy.js +15 -0
- package/package.json +1 -1
package/commandtypes.d.ts
CHANGED
|
@@ -77,6 +77,7 @@ export declare const enum CommandName {
|
|
|
77
77
|
GetRelativeLinePosition = "grlp",
|
|
78
78
|
GetSelection = "gs",
|
|
79
79
|
GetShapeData = "gsd",
|
|
80
|
+
GetSvg = "gsvg",
|
|
80
81
|
GetTextStyle = "gts",
|
|
81
82
|
GetUserId = "guid",
|
|
82
83
|
GetVisibleRect = "gvr",
|
|
@@ -369,6 +370,10 @@ export type CommandArgs = {
|
|
|
369
370
|
query: GetShapeDataQuery;
|
|
370
371
|
result: GetShapeDataResult;
|
|
371
372
|
};
|
|
373
|
+
[CommandName.GetSvg]: {
|
|
374
|
+
query: GetSvgQuery;
|
|
375
|
+
result: GetSvgResult;
|
|
376
|
+
};
|
|
372
377
|
[CommandName.GetTextStyle]: {
|
|
373
378
|
query: GetTextStyleQuery;
|
|
374
379
|
result: GetTextStyleResult;
|
|
@@ -1097,6 +1102,17 @@ export type GetShapeDataQuery = {
|
|
|
1097
1102
|
'n': string;
|
|
1098
1103
|
};
|
|
1099
1104
|
export type GetShapeDataResult = SerializedFieldType | SerializedDataError;
|
|
1105
|
+
export type GetSvgQuery = {
|
|
1106
|
+
/** Page ID to get an image of */
|
|
1107
|
+
'p': string;
|
|
1108
|
+
/** True to include the background of the page */
|
|
1109
|
+
'bg': boolean;
|
|
1110
|
+
/** If specified, the bounding box specifying what portion of the page to show */
|
|
1111
|
+
'bb'?: Box | undefined;
|
|
1112
|
+
/** If specified, only include these item IDs */
|
|
1113
|
+
'i'?: string[] | undefined;
|
|
1114
|
+
};
|
|
1115
|
+
export type GetSvgResult = Promise<string>;
|
|
1100
1116
|
export type GetTextStyleQuery = {
|
|
1101
1117
|
/** ID of the element to get text style from */
|
|
1102
1118
|
'id': string;
|
package/commandtypes.js
CHANGED
|
@@ -55,6 +55,7 @@ exports.commandTitles = new Map([
|
|
|
55
55
|
["grlp" /* CommandName.GetRelativeLinePosition */, 'GetRelativeLinePosition'],
|
|
56
56
|
["gs" /* CommandName.GetSelection */, 'GetSelection'],
|
|
57
57
|
["gsd" /* CommandName.GetShapeData */, 'GetShapeData'],
|
|
58
|
+
["gsvg" /* CommandName.GetSvg */, 'GetSvg'],
|
|
58
59
|
["gts" /* CommandName.GetTextStyle */, 'GetTextStyle'],
|
|
59
60
|
["guid" /* CommandName.GetUserId */, 'GetUserId'],
|
|
60
61
|
["gvr" /* CommandName.GetVisibleRect */, 'GetVisibleRect'],
|
package/core/checks.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export declare function isArray(val: unknown): val is unknown[];
|
|
|
98
98
|
* @return Whether variable is an array of the given type.
|
|
99
99
|
*/
|
|
100
100
|
export declare function isTypedArray<T>(typeGuard: (a: unknown) => a is T): (val: unknown) => val is T[];
|
|
101
|
+
export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : TupleOfHelper<T, N, []>) : never;
|
|
102
|
+
type TupleOfHelper<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : TupleOfHelper<T, N, [T, ...R]>;
|
|
103
|
+
export declare function isExactLength<T, N extends number>(arr: T[], exactLength: N): arr is Tuple<T, N>;
|
|
104
|
+
export declare function isAtLeastLength<T, N extends number>(arr: T[], minimumLength: N): arr is [...Tuple<T, N>, ...T[]];
|
|
101
105
|
/**
|
|
102
106
|
* Returns true if the specified object is either empty or all existing keys map to a nullish value
|
|
103
107
|
*
|
package/core/checks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
3
|
+
exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isAtLeastLength = exports.isExactLength = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Returns true if the specified value is not undefined.
|
|
6
6
|
*
|
|
@@ -154,6 +154,14 @@ function isTypedArray(typeGuard) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
exports.isTypedArray = isTypedArray;
|
|
157
|
+
function isExactLength(arr, exactLength) {
|
|
158
|
+
return arr.length === exactLength;
|
|
159
|
+
}
|
|
160
|
+
exports.isExactLength = isExactLength;
|
|
161
|
+
function isAtLeastLength(arr, minimumLength) {
|
|
162
|
+
return arr.length >= minimumLength;
|
|
163
|
+
}
|
|
164
|
+
exports.isAtLeastLength = isAtLeastLength;
|
|
157
165
|
/**
|
|
158
166
|
* Returns true if the specified object is either empty or all existing keys map to a nullish value
|
|
159
167
|
*
|
package/document/itemproxy.d.ts
CHANGED
|
@@ -43,6 +43,10 @@ export declare class ItemProxy extends ElementProxy {
|
|
|
43
43
|
* @param bb The bounding box to attempt to make this item fill
|
|
44
44
|
*/
|
|
45
45
|
setBoundingBox(bb: Box): void;
|
|
46
|
+
/**
|
|
47
|
+
* @returns The ID of the page containing this item
|
|
48
|
+
*/
|
|
49
|
+
getPageId(): string;
|
|
46
50
|
/**
|
|
47
51
|
* @returns The page containing this item
|
|
48
52
|
*/
|
package/document/itemproxy.js
CHANGED
|
@@ -71,11 +71,17 @@ class ItemProxy extends elementproxy_1.ElementProxy {
|
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* @returns The ID of the page containing this item
|
|
76
|
+
*/
|
|
77
|
+
getPageId() {
|
|
78
|
+
return this.client.sendCommand("gip" /* CommandName.GetItemPageId */, this.id);
|
|
79
|
+
}
|
|
74
80
|
/**
|
|
75
81
|
* @returns The page containing this item
|
|
76
82
|
*/
|
|
77
83
|
getPage() {
|
|
78
|
-
return this.client.getPageProxy(this.
|
|
84
|
+
return this.client.getPageProxy(this.getPageId());
|
|
79
85
|
}
|
|
80
86
|
/**
|
|
81
87
|
* @returns The x/y location of this item
|
package/document/pageproxy.d.ts
CHANGED
|
@@ -118,4 +118,12 @@ export declare class PageProxy extends ElementProxy {
|
|
|
118
118
|
prompt: string;
|
|
119
119
|
idToLucidId: Map<string, string>;
|
|
120
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
*
|
|
123
|
+
* @param items If specified, only include these items in the resulting SVG
|
|
124
|
+
* @param includeBackground If true, include the background of the page in the SVG. Otherwise the background is transparent.
|
|
125
|
+
* @param viewBox If specified, crop the resulting SVG to the specified bounding box in page coordinates
|
|
126
|
+
* @returns A promise resolving to an SVG string
|
|
127
|
+
*/
|
|
128
|
+
getSvg(items?: ItemProxy[], includeBackground?: boolean, viewBox?: Box): import("../commandtypes").GetSvgResult;
|
|
121
129
|
}
|
package/document/pageproxy.js
CHANGED
|
@@ -192,5 +192,20 @@ class PageProxy extends elementproxy_1.ElementProxy {
|
|
|
192
192
|
idToLucidId: new Map(Object.entries(result['id'])),
|
|
193
193
|
};
|
|
194
194
|
}
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* @param items If specified, only include these items in the resulting SVG
|
|
198
|
+
* @param includeBackground If true, include the background of the page in the SVG. Otherwise the background is transparent.
|
|
199
|
+
* @param viewBox If specified, crop the resulting SVG to the specified bounding box in page coordinates
|
|
200
|
+
* @returns A promise resolving to an SVG string
|
|
201
|
+
*/
|
|
202
|
+
getSvg(items, includeBackground = false, viewBox) {
|
|
203
|
+
return this.client.sendCommand("gsvg" /* CommandName.GetSvg */, {
|
|
204
|
+
'p': this.id,
|
|
205
|
+
'bb': viewBox,
|
|
206
|
+
'bg': includeBackground,
|
|
207
|
+
'i': items === null || items === void 0 ? void 0 : items.map((item) => item.id),
|
|
208
|
+
});
|
|
209
|
+
}
|
|
195
210
|
}
|
|
196
211
|
exports.PageProxy = PageProxy;
|