lucid-extension-sdk 0.0.122 → 0.0.123

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.122",
3
+ "version": "0.0.123",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "sdk/index.js",
6
6
  "types": "sdk/index.d.ts",
@@ -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: (0, object_1.entries)(fields).map(([name, { type, constraints, mapping }]) => {
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,
@@ -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
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fromEntries = exports.entries = exports.flatten = exports.objectEvery = void 0;
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)((0, object_1.entries)(req.query).map(([key, value]) => [
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 (0, object_1.entries)(headers !== null && headers !== void 0 ? headers : {})) {
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
  }
@@ -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");
@@ -148,7 +147,7 @@ class EditorClient {
148
147
  * @returns A promise that resolves to a map of setting names to current setting values
149
148
  */
150
149
  async getPackageSettings() {
151
- return new Map((0, object_1.entries)(await this.sendCommand("gps" /* CommandName.GetPackageSettings */, undefined)));
150
+ return new Map(Object.entries(await this.sendCommand("gps" /* CommandName.GetPackageSettings */, undefined)));
152
151
  }
153
152
  /**
154
153
  * @returns True if the current user is allowed to edit package settings on this installation
@@ -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),