lucid-extension-sdk 1.0.1 → 1.0.5
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/_validate_lucid-extension-sdk-ts_options.optionsvalid.d.ts +1 -1
- package/commandtypes.d.ts +211 -13
- package/core/checks.d.ts +93 -0
- package/core/checks.js +152 -0
- package/core/serializedfields.d.ts +58 -0
- package/core/serializedfields.js +37 -0
- package/document/blockclasses/blockproxyregistry.d.ts +8 -0
- package/document/blockdefinition.d.ts +2 -2
- package/document/blockproxy.js +1 -1
- package/document/documentproxy.d.ts +1 -1
- package/document/documentproxy.js +2 -4
- package/document/elementproxy.d.ts +2 -2
- package/document/elementproxy.js +4 -4
- package/document/groupproxy.d.ts +5 -2
- package/document/groupproxy.js +8 -5
- package/document/itemproxy.d.ts +5 -2
- package/document/itemproxy.js +6 -5
- package/document/linedefinition.d.ts +3 -3
- package/document/lineproxy.js +2 -2
- package/document/mapproxy.d.ts +4 -7
- package/document/mapproxy.js +7 -9
- package/document/pagedefinition.d.ts +2 -2
- package/document/pageproxy.d.ts +7 -4
- package/document/pageproxy.js +15 -18
- package/editorclient.d.ts +3 -1
- package/editorclient.js +27 -20
- package/index.d.ts +4 -4
- package/index.js +11 -4
- package/interop.d.ts +2 -2
- package/package.json +1 -5
- package/ui/menu.d.ts +11 -12
- package/ui/menu.js +18 -3
- package/ui/viewport.d.ts +1 -1
- package/ui/viewport.js +4 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
// /home/ben/.cache/bazel/_bazel_ben/8a63763d5555f12fa5e47c2c43ebd4e3/sandbox/linux-sandbox/
|
|
2
|
+
// /home/ben/.cache/bazel/_bazel_ben/8a63763d5555f12fa5e47c2c43ebd4e3/sandbox/linux-sandbox/6568/execroot/lucid/node_modules/@bazel/typescript/internal/ts_project_options_validator.js checked attributes for //extensibility/lucid-extension-sdk:lucid-extension-sdk-ts
|
|
3
3
|
// composite: false
|
|
4
4
|
// declaration: true
|
|
5
5
|
// declaration_map: false
|
package/commandtypes.d.ts
CHANGED
|
@@ -1,14 +1,26 @@
|
|
|
1
|
+
import { OffsetType } from './constants';
|
|
1
2
|
import { JsonSerializable } from './core/jsonserializable';
|
|
3
|
+
import { SerializedFieldType } from './core/serializedfields';
|
|
4
|
+
import { Point } from './math';
|
|
5
|
+
import { MenuType, MenuLocation } from './ui/menu';
|
|
2
6
|
export declare const enum CommandName {
|
|
7
|
+
AddMenuItem = "ami",
|
|
3
8
|
CreateBlock = "cb",
|
|
4
9
|
CreateLine = "cl",
|
|
5
10
|
CreatePage = "cp",
|
|
6
11
|
DeleteItem = "di",
|
|
7
12
|
DeletePage = "dp",
|
|
13
|
+
Download = "d",
|
|
8
14
|
ElementExists = "ee",
|
|
15
|
+
GetConnectedLines = "gcl",
|
|
16
|
+
GetCurrentPage = "gcp",
|
|
9
17
|
GetElementType = "get",
|
|
10
18
|
GetProperty = "gp",
|
|
19
|
+
GetRelativeLinePosition = "grlp",
|
|
20
|
+
GetSelection = "gs",
|
|
11
21
|
GetShapeData = "gsd",
|
|
22
|
+
HideModal = "hm",
|
|
23
|
+
KillExtension = "k",
|
|
12
24
|
ListBlocks = "lb",
|
|
13
25
|
ListGroups = "lg",
|
|
14
26
|
ListLines = "ll",
|
|
@@ -17,55 +29,241 @@ export declare const enum CommandName {
|
|
|
17
29
|
ListShapeData = "lsd",
|
|
18
30
|
ListTextAreas = "lta",
|
|
19
31
|
LoadBlockClasses = "lbc",
|
|
20
|
-
|
|
32
|
+
LogForTestCase = "log",
|
|
33
|
+
OffsetItems = "oi",
|
|
34
|
+
ReloadExtension = "r",
|
|
35
|
+
SetCurrentPage = "scp",
|
|
36
|
+
SetProperty = "sp",
|
|
37
|
+
ShowModal = "sm"
|
|
21
38
|
}
|
|
39
|
+
export declare type CommandArgs = {
|
|
40
|
+
[CommandName.AddMenuItem]: {
|
|
41
|
+
query: AddMenuItemQuery;
|
|
42
|
+
result: AddMenuItemResult;
|
|
43
|
+
};
|
|
44
|
+
[CommandName.CreateBlock]: {
|
|
45
|
+
query: CreateBlockQuery;
|
|
46
|
+
result: CreateBlockResult;
|
|
47
|
+
};
|
|
48
|
+
[CommandName.CreateLine]: {
|
|
49
|
+
query: CreateLineQuery;
|
|
50
|
+
result: CreateLineResult;
|
|
51
|
+
};
|
|
52
|
+
[CommandName.CreatePage]: {
|
|
53
|
+
query: CreatePageQuery;
|
|
54
|
+
result: CreatePageResult;
|
|
55
|
+
};
|
|
56
|
+
[CommandName.DeleteItem]: {
|
|
57
|
+
query: DeleteItemQuery;
|
|
58
|
+
result: DeleteItemResult;
|
|
59
|
+
};
|
|
60
|
+
[CommandName.DeletePage]: {
|
|
61
|
+
query: DeletePageQuery;
|
|
62
|
+
result: DeletePageResult;
|
|
63
|
+
};
|
|
64
|
+
[CommandName.Download]: {
|
|
65
|
+
query: DownloadQuery;
|
|
66
|
+
result: DownloadResult;
|
|
67
|
+
};
|
|
68
|
+
[CommandName.ElementExists]: {
|
|
69
|
+
query: ElementExistsQuery;
|
|
70
|
+
result: ElementExistsResult;
|
|
71
|
+
};
|
|
72
|
+
[CommandName.GetConnectedLines]: {
|
|
73
|
+
query: GetConnectedLinesQuery;
|
|
74
|
+
result: GetConnectedLinesResult;
|
|
75
|
+
};
|
|
76
|
+
[CommandName.GetCurrentPage]: {
|
|
77
|
+
query: GetCurrentPageQuery;
|
|
78
|
+
result: GetCurrentPageResult;
|
|
79
|
+
};
|
|
80
|
+
[CommandName.GetElementType]: {
|
|
81
|
+
query: GetElementTypeQuery;
|
|
82
|
+
result: GetElementTypeResult;
|
|
83
|
+
};
|
|
84
|
+
[CommandName.GetProperty]: {
|
|
85
|
+
query: GetPropertyQuery;
|
|
86
|
+
result: GetPropertyResult;
|
|
87
|
+
};
|
|
88
|
+
[CommandName.GetRelativeLinePosition]: {
|
|
89
|
+
query: GetRelativeLinePositionQuery;
|
|
90
|
+
result: GetRelativeLinePositionResult;
|
|
91
|
+
};
|
|
92
|
+
[CommandName.GetSelection]: {
|
|
93
|
+
query: GetSelectionQuery;
|
|
94
|
+
result: GetSelectionResult;
|
|
95
|
+
};
|
|
96
|
+
[CommandName.GetShapeData]: {
|
|
97
|
+
query: GetShapeDataQuery;
|
|
98
|
+
result: GetShapeDataResult;
|
|
99
|
+
};
|
|
100
|
+
[CommandName.HideModal]: {
|
|
101
|
+
query: HideModalQuery;
|
|
102
|
+
result: HideModalResult;
|
|
103
|
+
};
|
|
104
|
+
[CommandName.KillExtension]: {
|
|
105
|
+
query: KillExtensionQuery;
|
|
106
|
+
result: KillExtensionResult;
|
|
107
|
+
};
|
|
108
|
+
[CommandName.ListBlocks]: {
|
|
109
|
+
query: ListChildrenQuery;
|
|
110
|
+
result: ListChildrenResult;
|
|
111
|
+
};
|
|
112
|
+
[CommandName.ListGroups]: {
|
|
113
|
+
query: ListChildrenQuery;
|
|
114
|
+
result: ListChildrenResult;
|
|
115
|
+
};
|
|
116
|
+
[CommandName.ListLines]: {
|
|
117
|
+
query: ListChildrenQuery;
|
|
118
|
+
result: ListChildrenResult;
|
|
119
|
+
};
|
|
120
|
+
[CommandName.ListPages]: {
|
|
121
|
+
query: ListPagesQuery;
|
|
122
|
+
result: ListPagesResult;
|
|
123
|
+
};
|
|
124
|
+
[CommandName.ListProperties]: {
|
|
125
|
+
query: ListPropertiesQuery;
|
|
126
|
+
result: ListPropertiesResult;
|
|
127
|
+
};
|
|
128
|
+
[CommandName.ListShapeData]: {
|
|
129
|
+
query: ListShapeDataQuery;
|
|
130
|
+
result: ListShapeDataResult;
|
|
131
|
+
};
|
|
132
|
+
[CommandName.ListTextAreas]: {
|
|
133
|
+
query: ListTextAreasQuery;
|
|
134
|
+
result: ListTextAreasResult;
|
|
135
|
+
};
|
|
136
|
+
[CommandName.LoadBlockClasses]: {
|
|
137
|
+
query: LoadBlockClassesQuery;
|
|
138
|
+
result: LoadBlockClassesResult;
|
|
139
|
+
};
|
|
140
|
+
[CommandName.LogForTestCase]: {
|
|
141
|
+
query: JsonSerializable;
|
|
142
|
+
result: undefined;
|
|
143
|
+
};
|
|
144
|
+
[CommandName.OffsetItems]: {
|
|
145
|
+
query: OffsetItemsQuery;
|
|
146
|
+
result: OffsetItemsResult;
|
|
147
|
+
};
|
|
148
|
+
[CommandName.ReloadExtension]: {
|
|
149
|
+
query: ReloadExtensionQuery;
|
|
150
|
+
result: ReloadExtensionResult;
|
|
151
|
+
};
|
|
152
|
+
[CommandName.SetCurrentPage]: {
|
|
153
|
+
query: SetCurrentPageQuery;
|
|
154
|
+
result: SetCurrentPageResult;
|
|
155
|
+
};
|
|
156
|
+
[CommandName.SetProperty]: {
|
|
157
|
+
query: SetPropertyQuery;
|
|
158
|
+
result: SetPropertyResult;
|
|
159
|
+
};
|
|
160
|
+
[CommandName.ShowModal]: {
|
|
161
|
+
query: ShowModalQuery;
|
|
162
|
+
result: ShowModalResult;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
export declare type UnionToIntersection<T> = (T extends any ? (x: T) => unknown : never) extends (x: infer R) => unknown ? R : never;
|
|
166
|
+
export declare type AddMenuItemQuery = {
|
|
167
|
+
'l': string;
|
|
168
|
+
'a': string;
|
|
169
|
+
't': MenuType;
|
|
170
|
+
'loc': MenuLocation;
|
|
171
|
+
};
|
|
172
|
+
export declare type AddMenuItemResult = undefined;
|
|
22
173
|
export declare type CreateBlockQuery = {
|
|
23
174
|
'p'?: string;
|
|
24
175
|
'c': string;
|
|
25
176
|
};
|
|
26
|
-
export declare type CreateBlockResult = string
|
|
177
|
+
export declare type CreateBlockResult = string;
|
|
27
178
|
export declare type CreateLineQuery = {
|
|
28
179
|
'p'?: string;
|
|
29
180
|
};
|
|
30
|
-
export declare type CreateLineResult = string
|
|
31
|
-
export declare type CreatePageQuery =
|
|
32
|
-
export declare type CreatePageResult = string
|
|
181
|
+
export declare type CreateLineResult = string;
|
|
182
|
+
export declare type CreatePageQuery = void;
|
|
183
|
+
export declare type CreatePageResult = string;
|
|
33
184
|
export declare type DeleteItemQuery = string;
|
|
34
185
|
export declare type DeleteItemResult = boolean;
|
|
35
186
|
export declare type DeletePageQuery = string;
|
|
36
187
|
export declare type DeletePageResult = boolean;
|
|
37
|
-
export declare type
|
|
188
|
+
export declare type DownloadQuery = {
|
|
189
|
+
'f': string;
|
|
190
|
+
'd': string;
|
|
191
|
+
'm': string;
|
|
192
|
+
'b64': boolean;
|
|
193
|
+
};
|
|
194
|
+
export declare type DownloadResult = undefined;
|
|
195
|
+
export declare type ElementExistsQuery = {
|
|
196
|
+
'id'?: string | undefined;
|
|
197
|
+
};
|
|
38
198
|
export declare type ElementExistsResult = boolean;
|
|
39
|
-
export declare type GetElementTypeQuery =
|
|
199
|
+
export declare type GetElementTypeQuery = {
|
|
200
|
+
'id'?: string | undefined;
|
|
201
|
+
};
|
|
40
202
|
export declare type GetElementTypeResult = 'block' | 'line' | 'group' | 'page' | 'document' | 'generator' | 'panel';
|
|
203
|
+
export declare type GetConnectedLinesQuery = string;
|
|
204
|
+
export declare type GetConnectedLinesResult = string[];
|
|
205
|
+
export declare type GetCurrentPageQuery = void;
|
|
206
|
+
export declare type GetCurrentPageResult = string | undefined;
|
|
41
207
|
export declare type GetPropertyQuery = {
|
|
42
208
|
'id'?: string | undefined;
|
|
43
209
|
'p': string;
|
|
44
210
|
};
|
|
45
211
|
export declare type GetPropertyResult = JsonSerializable;
|
|
46
|
-
export declare type
|
|
212
|
+
export declare type GetRelativeLinePositionQuery = {
|
|
47
213
|
'id': string;
|
|
214
|
+
'p': number;
|
|
215
|
+
};
|
|
216
|
+
export declare type GetRelativeLinePositionResult = Point;
|
|
217
|
+
export declare type GetSelectionQuery = void;
|
|
218
|
+
export declare type GetSelectionResult = string[];
|
|
219
|
+
export declare type GetShapeDataQuery = {
|
|
220
|
+
'id'?: string | undefined;
|
|
48
221
|
'n': string;
|
|
49
222
|
};
|
|
50
|
-
export declare type GetShapeDataResult =
|
|
223
|
+
export declare type GetShapeDataResult = SerializedFieldType;
|
|
224
|
+
export declare type HideModalQuery = void;
|
|
225
|
+
export declare type HideModalResult = undefined;
|
|
226
|
+
export declare type KillExtensionQuery = void;
|
|
227
|
+
export declare type KillExtensionResult = undefined;
|
|
51
228
|
export declare type ListChildrenQuery = {
|
|
52
229
|
'id': string;
|
|
53
230
|
'd'?: boolean;
|
|
54
231
|
};
|
|
55
232
|
export declare type ListChildrenResult = string[];
|
|
56
|
-
export declare type ListPagesQuery =
|
|
233
|
+
export declare type ListPagesQuery = void;
|
|
57
234
|
export declare type ListPagesResult = string[];
|
|
58
|
-
export declare type ListPropertiesQuery =
|
|
235
|
+
export declare type ListPropertiesQuery = {
|
|
236
|
+
'id'?: string | undefined;
|
|
237
|
+
};
|
|
59
238
|
export declare type ListPropertiesResult = string[];
|
|
60
|
-
export declare type ListShapeDataQuery =
|
|
239
|
+
export declare type ListShapeDataQuery = {
|
|
240
|
+
'id'?: string | undefined;
|
|
241
|
+
};
|
|
61
242
|
export declare type ListShapeDataResult = string[];
|
|
62
243
|
export declare type ListTextAreasQuery = string;
|
|
63
244
|
export declare type ListTextAreasResult = string[];
|
|
64
245
|
export declare type LoadBlockClassesQuery = string[];
|
|
65
246
|
export declare type LoadBlockClassesResult = Promise<undefined>;
|
|
247
|
+
export declare type OffsetItemsQuery = {
|
|
248
|
+
'ids': string[];
|
|
249
|
+
't': OffsetType;
|
|
250
|
+
'o': Point;
|
|
251
|
+
};
|
|
252
|
+
export declare type OffsetItemsResult = undefined;
|
|
253
|
+
export declare type ReloadExtensionQuery = void;
|
|
254
|
+
export declare type ReloadExtensionResult = undefined;
|
|
255
|
+
export declare type SetCurrentPageQuery = string;
|
|
256
|
+
export declare type SetCurrentPageResult = undefined;
|
|
66
257
|
export declare type SetPropertyQuery = {
|
|
67
|
-
'id'
|
|
258
|
+
'id'?: string | undefined;
|
|
68
259
|
'p': string;
|
|
69
260
|
'v'?: JsonSerializable;
|
|
70
261
|
};
|
|
71
262
|
export declare type SetPropertyResult = undefined;
|
|
263
|
+
export declare type ShowModalQuery = {
|
|
264
|
+
't': string;
|
|
265
|
+
'w': number;
|
|
266
|
+
'h': number;
|
|
267
|
+
'c': string;
|
|
268
|
+
};
|
|
269
|
+
export declare type ShowModalResult = undefined;
|
package/core/checks.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true if the specified value is not undefined.
|
|
3
|
+
*
|
|
4
|
+
* @param val Variable to test.
|
|
5
|
+
* @return Whether variable is defined.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isDef<F>(val: F | undefined): val is F;
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if the specified value is null.
|
|
10
|
+
* @param val Variable to test.
|
|
11
|
+
* @return Whether variable is null.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isNull(val: unknown): val is null;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the specified value is undefined.
|
|
16
|
+
* @param val Variable to test.
|
|
17
|
+
* @return Whether variable is undefined.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isUndefined(val: unknown): val is undefined;
|
|
20
|
+
/**
|
|
21
|
+
* Returns true if the specified value is defined and not null.
|
|
22
|
+
* @param val Variable to test.
|
|
23
|
+
* @return Whether variable is defined and not null.
|
|
24
|
+
*/
|
|
25
|
+
export declare function isDefAndNotNull<F>(val: F | null | undefined): val is F;
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if the specified value is null or undefined.
|
|
28
|
+
* @param val Variable to test
|
|
29
|
+
* @return Whether the variable is null or undefined.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isNullish(val: unknown): val is null | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if the specified value is a string.
|
|
34
|
+
* @param val Variable to test.
|
|
35
|
+
* @return Whether variable is a string.
|
|
36
|
+
*/
|
|
37
|
+
export declare function isString(val: unknown): val is string;
|
|
38
|
+
/**
|
|
39
|
+
* Returns true if the specified value is a boolean.
|
|
40
|
+
* @param val Variable to test.
|
|
41
|
+
* @return Whether variable is boolean.
|
|
42
|
+
*/
|
|
43
|
+
export declare function isBoolean(val: unknown): val is boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Returns true if the specified value is a number.
|
|
46
|
+
* @param val Variable to test.
|
|
47
|
+
* @return Whether variable is a number.
|
|
48
|
+
*/
|
|
49
|
+
export declare function isNumber(val: unknown): val is number;
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if the specified value is an integer.
|
|
52
|
+
* @param val Variable to test.
|
|
53
|
+
* @return Whether variable is an integer.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isInt(val: unknown): val is number;
|
|
56
|
+
export declare function isFunction(val: unknown): val is (...unknownArgs: any[]) => unknown;
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if the specified value is an object (i.e. it's safe to do property accesses on it).
|
|
59
|
+
*
|
|
60
|
+
* This is safer than using goog.isObject directly (this is its code inlined) because it doesn't introduce an `any`.
|
|
61
|
+
* @param val Variable to test.
|
|
62
|
+
* @return Whether variable is an object.
|
|
63
|
+
*/
|
|
64
|
+
export declare function isObject(val: unknown): val is Record<string, unknown>;
|
|
65
|
+
/**
|
|
66
|
+
* Returns true if the specified value is an array.
|
|
67
|
+
*
|
|
68
|
+
* This is safer than using Array.isArray directly because it doesn't introduce an `any` type.
|
|
69
|
+
* @param val Variable to test.
|
|
70
|
+
* @return Whether variable is an array.
|
|
71
|
+
*/
|
|
72
|
+
export declare function isArray(val: unknown): val is unknown[];
|
|
73
|
+
/**
|
|
74
|
+
* Returns true if the specified value is an array and every element passes the type guard function.
|
|
75
|
+
*
|
|
76
|
+
* @param val Variable to test.
|
|
77
|
+
* @param typeGuard the type guard function to test every element in the array.
|
|
78
|
+
* @return Whether variable is an array of the given type.
|
|
79
|
+
*/
|
|
80
|
+
export declare function isTypedArray<T>(typeGuard: (a: unknown) => a is T): (val: unknown) => val is T[];
|
|
81
|
+
/**
|
|
82
|
+
* Returns true if the specified object is either empty or all existing keys map to a nullish value
|
|
83
|
+
*
|
|
84
|
+
* @param val Variable to test
|
|
85
|
+
* @return Whether variable is empty or maps exclusively to nullish values
|
|
86
|
+
*/
|
|
87
|
+
export declare function isEmptyOrNullishObject(val: unknown): val is {};
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Prefer isUnknown
|
|
90
|
+
*/
|
|
91
|
+
export declare function isAny(val: unknown): val is any;
|
|
92
|
+
export declare function isUnknown(val: unknown): val is unknown;
|
|
93
|
+
export declare function isPromise(val: unknown): val is Promise<unknown>;
|
package/core/checks.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isObject = exports.isFunction = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Returns true if the specified value is not undefined.
|
|
6
|
+
*
|
|
7
|
+
* @param val Variable to test.
|
|
8
|
+
* @return Whether variable is defined.
|
|
9
|
+
*/
|
|
10
|
+
function isDef(val) {
|
|
11
|
+
return val !== undefined;
|
|
12
|
+
}
|
|
13
|
+
exports.isDef = isDef;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the specified value is null.
|
|
16
|
+
* @param val Variable to test.
|
|
17
|
+
* @return Whether variable is null.
|
|
18
|
+
*/
|
|
19
|
+
function isNull(val) {
|
|
20
|
+
return val === null;
|
|
21
|
+
}
|
|
22
|
+
exports.isNull = isNull;
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if the specified value is undefined.
|
|
25
|
+
* @param val Variable to test.
|
|
26
|
+
* @return Whether variable is undefined.
|
|
27
|
+
*/
|
|
28
|
+
function isUndefined(val) {
|
|
29
|
+
return val === undefined;
|
|
30
|
+
}
|
|
31
|
+
exports.isUndefined = isUndefined;
|
|
32
|
+
/**
|
|
33
|
+
* Returns true if the specified value is defined and not null.
|
|
34
|
+
* @param val Variable to test.
|
|
35
|
+
* @return Whether variable is defined and not null.
|
|
36
|
+
*/
|
|
37
|
+
function isDefAndNotNull(val) {
|
|
38
|
+
return val != null;
|
|
39
|
+
}
|
|
40
|
+
exports.isDefAndNotNull = isDefAndNotNull;
|
|
41
|
+
/**
|
|
42
|
+
* Returns true if the specified value is null or undefined.
|
|
43
|
+
* @param val Variable to test
|
|
44
|
+
* @return Whether the variable is null or undefined.
|
|
45
|
+
*/
|
|
46
|
+
function isNullish(val) {
|
|
47
|
+
return val == null;
|
|
48
|
+
}
|
|
49
|
+
exports.isNullish = isNullish;
|
|
50
|
+
/**
|
|
51
|
+
* Returns true if the specified value is a string.
|
|
52
|
+
* @param val Variable to test.
|
|
53
|
+
* @return Whether variable is a string.
|
|
54
|
+
*/
|
|
55
|
+
function isString(val) {
|
|
56
|
+
return typeof val == 'string';
|
|
57
|
+
}
|
|
58
|
+
exports.isString = isString;
|
|
59
|
+
/**
|
|
60
|
+
* Returns true if the specified value is a boolean.
|
|
61
|
+
* @param val Variable to test.
|
|
62
|
+
* @return Whether variable is boolean.
|
|
63
|
+
*/
|
|
64
|
+
function isBoolean(val) {
|
|
65
|
+
return typeof val == 'boolean';
|
|
66
|
+
}
|
|
67
|
+
exports.isBoolean = isBoolean;
|
|
68
|
+
/**
|
|
69
|
+
* Returns true if the specified value is a number.
|
|
70
|
+
* @param val Variable to test.
|
|
71
|
+
* @return Whether variable is a number.
|
|
72
|
+
*/
|
|
73
|
+
function isNumber(val) {
|
|
74
|
+
return typeof val == 'number';
|
|
75
|
+
}
|
|
76
|
+
exports.isNumber = isNumber;
|
|
77
|
+
/**
|
|
78
|
+
* Returns true if the specified value is an integer.
|
|
79
|
+
* @param val Variable to test.
|
|
80
|
+
* @return Whether variable is an integer.
|
|
81
|
+
*/
|
|
82
|
+
function isInt(val) {
|
|
83
|
+
return isNumber(val) && isFinite(val) && val % 1 == 0;
|
|
84
|
+
}
|
|
85
|
+
exports.isInt = isInt;
|
|
86
|
+
function isFunction(val) {
|
|
87
|
+
return typeof val === 'function';
|
|
88
|
+
}
|
|
89
|
+
exports.isFunction = isFunction;
|
|
90
|
+
/**
|
|
91
|
+
* Returns true if the specified value is an object (i.e. it's safe to do property accesses on it).
|
|
92
|
+
*
|
|
93
|
+
* This is safer than using goog.isObject directly (this is its code inlined) because it doesn't introduce an `any`.
|
|
94
|
+
* @param val Variable to test.
|
|
95
|
+
* @return Whether variable is an object.
|
|
96
|
+
*/
|
|
97
|
+
function isObject(val) {
|
|
98
|
+
const type = typeof val;
|
|
99
|
+
return (type == 'object' && val != null) || type == 'function';
|
|
100
|
+
}
|
|
101
|
+
exports.isObject = isObject;
|
|
102
|
+
/**
|
|
103
|
+
* Returns true if the specified value is an array.
|
|
104
|
+
*
|
|
105
|
+
* This is safer than using Array.isArray directly because it doesn't introduce an `any` type.
|
|
106
|
+
* @param val Variable to test.
|
|
107
|
+
* @return Whether variable is an array.
|
|
108
|
+
*/
|
|
109
|
+
function isArray(val) {
|
|
110
|
+
return Array.isArray(val);
|
|
111
|
+
}
|
|
112
|
+
exports.isArray = isArray;
|
|
113
|
+
/**
|
|
114
|
+
* Returns true if the specified value is an array and every element passes the type guard function.
|
|
115
|
+
*
|
|
116
|
+
* @param val Variable to test.
|
|
117
|
+
* @param typeGuard the type guard function to test every element in the array.
|
|
118
|
+
* @return Whether variable is an array of the given type.
|
|
119
|
+
*/
|
|
120
|
+
function isTypedArray(typeGuard) {
|
|
121
|
+
return function (val) {
|
|
122
|
+
return isArray(val) && val.every(typeGuard);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
exports.isTypedArray = isTypedArray;
|
|
126
|
+
/**
|
|
127
|
+
* Returns true if the specified object is either empty or all existing keys map to a nullish value
|
|
128
|
+
*
|
|
129
|
+
* @param val Variable to test
|
|
130
|
+
* @return Whether variable is empty or maps exclusively to nullish values
|
|
131
|
+
*/
|
|
132
|
+
function isEmptyOrNullishObject(val) {
|
|
133
|
+
return !(val &&
|
|
134
|
+
typeof val === 'object' &&
|
|
135
|
+
Object.keys(val).find((key) => isDefAndNotNull(val[key])));
|
|
136
|
+
}
|
|
137
|
+
exports.isEmptyOrNullishObject = isEmptyOrNullishObject;
|
|
138
|
+
/**
|
|
139
|
+
* @deprecated Prefer isUnknown
|
|
140
|
+
*/
|
|
141
|
+
function isAny(val) {
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
exports.isAny = isAny;
|
|
145
|
+
function isUnknown(val) {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
exports.isUnknown = isUnknown;
|
|
149
|
+
function isPromise(val) {
|
|
150
|
+
return isObject(val) && isFunction(val.then) && isFunction(val.catch);
|
|
151
|
+
}
|
|
152
|
+
exports.isPromise = isPromise;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Once we have full server support for complex field types,
|
|
3
|
+
* we should be able to support object/array data here
|
|
4
|
+
*/
|
|
5
|
+
export declare type SerializedFieldType = number | boolean | string | null | SerializedLucidDateObject | SerializedColorObjectFieldType | SerializedLucidDictionary | SerializedLucidCurrency | undefined | Array<SerializedFieldType>;
|
|
6
|
+
export declare type SerializedLucidDictionary = {
|
|
7
|
+
'dict': {
|
|
8
|
+
[index: string]: SerializedFieldType;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare type SerializedLucidCurrency = {
|
|
12
|
+
'a': number;
|
|
13
|
+
't': string;
|
|
14
|
+
};
|
|
15
|
+
export declare type SerializedFields = {
|
|
16
|
+
[fieldName: string]: SerializedFieldType;
|
|
17
|
+
};
|
|
18
|
+
export declare type SerializedLucidDateObject = {
|
|
19
|
+
'ms': number;
|
|
20
|
+
'isDateOnly'?: boolean;
|
|
21
|
+
};
|
|
22
|
+
export declare type SerializedRGBColor = {
|
|
23
|
+
'r': number;
|
|
24
|
+
'g': number;
|
|
25
|
+
'b': number;
|
|
26
|
+
'a'?: number;
|
|
27
|
+
't'?: number;
|
|
28
|
+
'c'?: undefined;
|
|
29
|
+
'm'?: undefined;
|
|
30
|
+
'y'?: undefined;
|
|
31
|
+
'k'?: undefined;
|
|
32
|
+
};
|
|
33
|
+
export declare type SerializedCMYKColor = {
|
|
34
|
+
'c': number;
|
|
35
|
+
'm': number;
|
|
36
|
+
'y': number;
|
|
37
|
+
'k': number;
|
|
38
|
+
'a'?: number;
|
|
39
|
+
't'?: number;
|
|
40
|
+
'r'?: undefined;
|
|
41
|
+
'g'?: undefined;
|
|
42
|
+
'b'?: undefined;
|
|
43
|
+
};
|
|
44
|
+
export declare type SerializedCorrectedColor = {
|
|
45
|
+
'cR': number;
|
|
46
|
+
'cG': number;
|
|
47
|
+
'cB': number;
|
|
48
|
+
};
|
|
49
|
+
export declare type SerializedColorObject = SerializedRGBColor | SerializedCMYKColor | (SerializedCMYKColor & SerializedCorrectedColor);
|
|
50
|
+
export declare type SerializedColorObjectFieldType = {
|
|
51
|
+
'color': SerializedColorObject;
|
|
52
|
+
};
|
|
53
|
+
export declare function isSerializedColorObjectFieldType(value: any): value is SerializedColorObjectFieldType;
|
|
54
|
+
export declare function isSerializedLucidDictionary(value: any): value is SerializedLucidDictionary;
|
|
55
|
+
export declare function isSerializedLucidCurrency(value: any): value is SerializedLucidCurrency;
|
|
56
|
+
export declare function isSerializedLucidDateObject(value: any): value is SerializedLucidDateObject;
|
|
57
|
+
export declare function isSerializedFieldType(value: any): value is SerializedFieldType;
|
|
58
|
+
export declare function isSerializedFields(value: unknown): value is SerializedFields;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSerializedFields = exports.isSerializedFieldType = exports.isSerializedLucidDateObject = exports.isSerializedLucidCurrency = exports.isSerializedLucidDictionary = exports.isSerializedColorObjectFieldType = void 0;
|
|
4
|
+
const checks_1 = require("./checks");
|
|
5
|
+
function isSerializedColorObjectFieldType(value) {
|
|
6
|
+
return checks_1.isObject(value) && checks_1.isObject(value['color']);
|
|
7
|
+
}
|
|
8
|
+
exports.isSerializedColorObjectFieldType = isSerializedColorObjectFieldType;
|
|
9
|
+
function isSerializedLucidDictionary(value) {
|
|
10
|
+
return checks_1.isObject(value) && Object.values(value).every(isSerializedFieldType);
|
|
11
|
+
}
|
|
12
|
+
exports.isSerializedLucidDictionary = isSerializedLucidDictionary;
|
|
13
|
+
function isSerializedLucidCurrency(value) {
|
|
14
|
+
return checks_1.isObject(value) && checks_1.isNumber(value['a']) && checks_1.isString(value['t']);
|
|
15
|
+
}
|
|
16
|
+
exports.isSerializedLucidCurrency = isSerializedLucidCurrency;
|
|
17
|
+
function isSerializedLucidDateObject(value) {
|
|
18
|
+
var _a;
|
|
19
|
+
return checks_1.isObject(value) && checks_1.isNumber(value['ms']) && checks_1.isBoolean((_a = value['isDateOnly']) !== null && _a !== void 0 ? _a : true);
|
|
20
|
+
}
|
|
21
|
+
exports.isSerializedLucidDateObject = isSerializedLucidDateObject;
|
|
22
|
+
function isSerializedFieldType(value) {
|
|
23
|
+
return (value == null ||
|
|
24
|
+
checks_1.isNumber(value) ||
|
|
25
|
+
checks_1.isString(value) ||
|
|
26
|
+
checks_1.isBoolean(value) ||
|
|
27
|
+
isSerializedLucidDictionary(value) ||
|
|
28
|
+
isSerializedLucidCurrency(value) ||
|
|
29
|
+
(checks_1.isArray(value) && value.every(isSerializedFieldType)) ||
|
|
30
|
+
isSerializedLucidDateObject(value) ||
|
|
31
|
+
isSerializedColorObjectFieldType(value));
|
|
32
|
+
}
|
|
33
|
+
exports.isSerializedFieldType = isSerializedFieldType;
|
|
34
|
+
function isSerializedFields(value) {
|
|
35
|
+
return checks_1.isObject(value) && Object.values(value).every(isSerializedFieldType);
|
|
36
|
+
}
|
|
37
|
+
exports.isSerializedFields = isSerializedFields;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { BlockProxy } from '../blockproxy';
|
|
2
|
+
/**
|
|
3
|
+
* The base BlockProxy class provides no special functionality for any specific type of block.
|
|
4
|
+
*
|
|
5
|
+
* To provide direct type-safe support for specific block types, extend BlockProxy and add a
|
|
6
|
+
* classNameRegex, then include your new block proxy in the allProxyClasses list. Then, whenever
|
|
7
|
+
* we construct a proxy to represent a block on the document, we will check each available
|
|
8
|
+
* proxy class and use one of these if available.
|
|
9
|
+
*/
|
|
2
10
|
export declare type BlockProxyConstructor = typeof BlockProxy & {
|
|
3
11
|
classNameRegex: RegExp;
|
|
4
12
|
};
|
package/document/blockproxy.js
CHANGED
|
@@ -11,7 +11,7 @@ class BlockProxy extends itemproxy_1.ItemProxy {
|
|
|
11
11
|
return this.properties.get('Rotation');
|
|
12
12
|
}
|
|
13
13
|
getConnectedLines() {
|
|
14
|
-
const ids = this.client.sendCommand(
|
|
14
|
+
const ids = this.client.sendCommand("gcl" /* GetConnectedLines */, this.id);
|
|
15
15
|
return ids.map((id) => new lineproxy_1.LineProxy(id, this.client));
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { EditorClient } from '../editorclient';
|
|
2
2
|
import { ElementProxy } from './elementproxy';
|
|
3
3
|
import { MapProxy } from './mapproxy';
|
|
4
|
-
import { PageProxy } from './pageproxy';
|
|
5
4
|
import { PageDefinition } from './pagedefinition';
|
|
5
|
+
import { PageProxy } from './pageproxy';
|
|
6
6
|
export declare class DocumentProxy extends ElementProxy {
|
|
7
7
|
readonly pages: MapProxy<string, PageProxy>;
|
|
8
8
|
constructor(client: EditorClient);
|
|
@@ -7,12 +7,10 @@ const pageproxy_1 = require("./pageproxy");
|
|
|
7
7
|
class DocumentProxy extends elementproxy_1.ElementProxy {
|
|
8
8
|
constructor(client) {
|
|
9
9
|
super('', client);
|
|
10
|
-
this.pages = new mapproxy_1.MapProxy(this.client
|
|
10
|
+
this.pages = new mapproxy_1.MapProxy(() => this.client.sendCommand("lp" /* ListPages */, undefined), (pageId) => new pageproxy_1.PageProxy(pageId, this.client));
|
|
11
11
|
}
|
|
12
12
|
addPage(def) {
|
|
13
|
-
const id = this.client.sendCommand(
|
|
14
|
-
'Title': def.title,
|
|
15
|
-
});
|
|
13
|
+
const id = this.client.sendCommand("cp" /* CreatePage */, undefined);
|
|
16
14
|
const page = new pageproxy_1.PageProxy(id, this.client);
|
|
17
15
|
page.setTitle(def.title);
|
|
18
16
|
return page;
|