lucid-extension-sdk 0.0.122 → 0.0.124
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/package.json +1 -1
- package/sdk/core/base64.js +6 -0
- package/sdk/core/data/fieldspecification.js +1 -2
- package/sdk/core/object.d.ts +0 -3
- package/sdk/core/object.js +1 -6
- package/sdk/dataconnector/debugserver.js +2 -2
- package/sdk/editorclient.d.ts +8 -11
- package/sdk/editorclient.js +10 -18
- package/sdk/ui/viewport.js +1 -1
package/package.json
CHANGED
package/sdk/core/base64.js
CHANGED
|
@@ -30,6 +30,9 @@ function decodeBase64(base64String) {
|
|
|
30
30
|
const enc2 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
31
31
|
const enc3 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
32
32
|
const enc4 = charCodeToEncodedInt[base64String.charCodeAt(inputIndex++)];
|
|
33
|
+
if (enc1 === undefined || enc2 === undefined || enc3 === undefined || enc4 === undefined) {
|
|
34
|
+
throw new Error('char code to encoded int contains an undefined index');
|
|
35
|
+
}
|
|
33
36
|
//Read 8 total bits into each of the output values. Skip one byte
|
|
34
37
|
//for each padding = at the end of the string
|
|
35
38
|
output[outputIndex] = (enc1 << 2) | (enc2 >> 4);
|
|
@@ -55,6 +58,9 @@ function encodeBase64(byteArray) {
|
|
|
55
58
|
const byte1 = byteArray[inputIndex++];
|
|
56
59
|
const byte2 = byteArray[inputIndex++];
|
|
57
60
|
const byte3 = byteArray[inputIndex++];
|
|
61
|
+
if (byte1 === undefined || byte2 === undefined || byte3 === undefined) {
|
|
62
|
+
throw new Error('byteArray contains undefined indexes');
|
|
63
|
+
}
|
|
58
64
|
const enc1 = byte1 >> 2; // first 6 bits of byte1
|
|
59
65
|
const enc2 = ((byte1 & 3) << 4) | (byte2 >> 4); // last 2 bits of byte1 and first 4 bits of byte2
|
|
60
66
|
const enc3 = ((byte2 & 15) << 2) | (byte3 >> 6); // last 4 bits of byte2 and first 2 bits of byte3
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FormattedPrimaryKey = exports.declareSchema = void 0;
|
|
4
|
-
const object_1 = require("../object");
|
|
5
4
|
function isArrayAndAssertReadonly(val) {
|
|
6
5
|
return Array.isArray(val);
|
|
7
6
|
}
|
|
@@ -18,7 +17,7 @@ function declareSchema({ primaryKey, fields }) {
|
|
|
18
17
|
const primaryKeyObj = new FormattedPrimaryKey(...primaryKey);
|
|
19
18
|
return {
|
|
20
19
|
example: fields,
|
|
21
|
-
array:
|
|
20
|
+
array: Object.entries(fields).map(([name, { type, constraints, mapping }]) => {
|
|
22
21
|
return {
|
|
23
22
|
'name': name,
|
|
24
23
|
'type': isArrayAndAssertReadonly(type) ? type.slice() : type,
|
package/sdk/core/object.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ export declare function objectEvery<T, O extends {
|
|
|
2
2
|
[key: string]: any;
|
|
3
3
|
}>(obj: O, f: (this: T | undefined, _0: O[typeof _1], _1: string & keyof O, _2: O) => any, opt_this?: T): boolean;
|
|
4
4
|
export declare function flatten<T>(a: T[][]): T[];
|
|
5
|
-
export declare function entries<T>(obj: {
|
|
6
|
-
[key: string]: T;
|
|
7
|
-
}): [string, T][];
|
|
8
5
|
export declare function fromEntries<K extends PropertyKey, T>(entries: Iterable<readonly [K, T]>): {
|
|
9
6
|
[key in K]: T;
|
|
10
7
|
};
|
package/sdk/core/object.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fromEntries = exports.
|
|
3
|
+
exports.fromEntries = exports.flatten = exports.objectEvery = void 0;
|
|
4
4
|
function objectEvery(obj, f, opt_this) {
|
|
5
5
|
for (const key in obj) {
|
|
6
6
|
if (!f.call(opt_this, obj[key], key, obj)) {
|
|
@@ -18,11 +18,6 @@ function flatten(a) {
|
|
|
18
18
|
return result;
|
|
19
19
|
}
|
|
20
20
|
exports.flatten = flatten;
|
|
21
|
-
// TODO: Placeholder until we adopt ES8 and can use Object.entries(obj)
|
|
22
|
-
function entries(obj) {
|
|
23
|
-
return Object.keys(obj).map((key) => [key, obj[key]]);
|
|
24
|
-
}
|
|
25
|
-
exports.entries = entries;
|
|
26
21
|
// TODO: Placeholder until we adopt ES8 and can use Object.fromEntries(obj)
|
|
27
22
|
function fromEntries(entries) {
|
|
28
23
|
const result = {};
|
|
@@ -32,12 +32,12 @@ function routeDebugServer(dataConnector, options) {
|
|
|
32
32
|
const { body, status, headers } = await route({
|
|
33
33
|
body: req.body.toString(),
|
|
34
34
|
headers: reqHeaders,
|
|
35
|
-
query: (0, object_1.fromEntries)(
|
|
35
|
+
query: (0, object_1.fromEntries)(Object.entries(req.query).map(([key, value]) => [
|
|
36
36
|
key,
|
|
37
37
|
typeof value === 'string' ? value : undefined,
|
|
38
38
|
])),
|
|
39
39
|
});
|
|
40
|
-
for (const [name, value] of
|
|
40
|
+
for (const [name, value] of Object.entries(headers !== null && headers !== void 0 ? headers : {})) {
|
|
41
41
|
if (typeof value === 'string') {
|
|
42
42
|
res.setHeader(name, value);
|
|
43
43
|
}
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -20,6 +20,13 @@ export declare type DataActionResponse = {
|
|
|
20
20
|
/** The body of the HTTP Response (otherwise) */
|
|
21
21
|
'text': string;
|
|
22
22
|
});
|
|
23
|
+
export declare type DataActionOptions = {
|
|
24
|
+
dataConnectorName: string;
|
|
25
|
+
actionName: string;
|
|
26
|
+
actionData?: unknown;
|
|
27
|
+
syncDataSourceIdNonce?: string;
|
|
28
|
+
asynchronous?: boolean;
|
|
29
|
+
};
|
|
23
30
|
export declare class EditorClient {
|
|
24
31
|
private nextId;
|
|
25
32
|
private readonly callbacks;
|
|
@@ -58,17 +65,7 @@ export declare class EditorClient {
|
|
|
58
65
|
* @deprecated Use createUserImage instead.
|
|
59
66
|
*/
|
|
60
67
|
experimentalCreateUserImage(mediaType: string, data: Uint8Array | string): Promise<string>;
|
|
61
|
-
|
|
62
|
-
*
|
|
63
|
-
* @param flowName
|
|
64
|
-
* @param dataConnectorName
|
|
65
|
-
* @param syncDataSourceId
|
|
66
|
-
* @param flowData
|
|
67
|
-
* @param async
|
|
68
|
-
* @returns
|
|
69
|
-
* @throws A string with an error from the data sync server
|
|
70
|
-
*/
|
|
71
|
-
performDataAction(flowName: string, dataConnectorName: string, syncDataSourceId?: undefined | string, flowData?: unknown, async?: boolean): Promise<DataActionResponse>;
|
|
68
|
+
performDataAction(options: DataActionOptions): Promise<DataActionResponse>;
|
|
72
69
|
/**
|
|
73
70
|
* If the extension package containing this editor extension has configurable settings,
|
|
74
71
|
* show a standard modal allowing the user to view or change those settings.
|
package/sdk/editorclient.js
CHANGED
|
@@ -4,7 +4,6 @@ exports.EditorClient = void 0;
|
|
|
4
4
|
const commandtypes_1 = require("./commandtypes");
|
|
5
5
|
const base64_1 = require("./core/base64");
|
|
6
6
|
const checks_1 = require("./core/checks");
|
|
7
|
-
const object_1 = require("./core/object");
|
|
8
7
|
const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
|
|
9
8
|
const unfurldetails_1 = require("./core/unfurl/unfurldetails");
|
|
10
9
|
const unfurlrefresherrortype_1 = require("./core/unfurl/unfurlrefresherrortype");
|
|
@@ -97,23 +96,16 @@ class EditorClient {
|
|
|
97
96
|
experimentalCreateUserImage(mediaType, data) {
|
|
98
97
|
return this.createUserImage(mediaType, data);
|
|
99
98
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
* @param syncDataSourceId
|
|
105
|
-
* @param flowData
|
|
106
|
-
* @param async
|
|
107
|
-
* @returns
|
|
108
|
-
* @throws A string with an error from the data sync server
|
|
109
|
-
*/
|
|
110
|
-
async performDataAction(flowName, dataConnectorName, syncDataSourceId = undefined, flowData = undefined, async = true) {
|
|
99
|
+
async performDataAction(options) {
|
|
100
|
+
if (options.asynchronous === undefined) {
|
|
101
|
+
options.asynchronous = true;
|
|
102
|
+
}
|
|
111
103
|
const result = await this.sendCommand("da" /* CommandName.DataAction */, {
|
|
112
|
-
'fn':
|
|
113
|
-
'a':
|
|
114
|
-
's':
|
|
115
|
-
'fd':
|
|
116
|
-
'n': dataConnectorName,
|
|
104
|
+
'fn': options.actionName,
|
|
105
|
+
'a': options.asynchronous,
|
|
106
|
+
's': options.syncDataSourceIdNonce,
|
|
107
|
+
'fd': options.actionData,
|
|
108
|
+
'n': options.dataConnectorName,
|
|
117
109
|
});
|
|
118
110
|
if ('t' in result) {
|
|
119
111
|
return {
|
|
@@ -148,7 +140,7 @@ class EditorClient {
|
|
|
148
140
|
* @returns A promise that resolves to a map of setting names to current setting values
|
|
149
141
|
*/
|
|
150
142
|
async getPackageSettings() {
|
|
151
|
-
return new Map(
|
|
143
|
+
return new Map(Object.entries(await this.sendCommand("gps" /* CommandName.GetPackageSettings */, undefined)));
|
|
152
144
|
}
|
|
153
145
|
/**
|
|
154
146
|
* @returns True if the current user is allowed to edit package settings on this installation
|
package/sdk/ui/viewport.js
CHANGED
|
@@ -44,7 +44,7 @@ class Viewport {
|
|
|
44
44
|
*/
|
|
45
45
|
focusCameraOnItems(items) {
|
|
46
46
|
const bb = (0, math_1.combinedBoundingBox)(items.map((e) => e.getBoundingBox()));
|
|
47
|
-
if (bb) {
|
|
47
|
+
if (bb && items[0]) {
|
|
48
48
|
//TODO: A reasonable max zoom level (e.g. 200%)
|
|
49
49
|
this.client.sendCommand("av" /* CommandName.AnimateViewport */, {
|
|
50
50
|
'bb': (0, math_1.padBox)(bb, 80),
|