lucid-extension-sdk 0.0.454 → 0.0.456

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.
@@ -14,6 +14,8 @@ export declare const FieldConstraintType: {
14
14
  readonly NO_WHITESPACE: "noWhitespace";
15
15
  readonly UNIQUE_EDIT: "uniqueEditType";
16
16
  readonly MAX_LENGTH: "maxLength";
17
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
18
+ /** @deprecated Use MAX_DECIMAL_PLACES instead. This key mapped to the wrong string value and never matched the backend. */
17
19
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
18
20
  };
19
21
  export type FieldConstraintType = (typeof FieldConstraintType)[keyof typeof FieldConstraintType];
@@ -26,8 +28,10 @@ export declare const isFieldConstraintType: (x: unknown) => x is {} extends {
26
28
  readonly NO_WHITESPACE: "noWhitespace";
27
29
  readonly UNIQUE_EDIT: "uniqueEditType";
28
30
  readonly MAX_LENGTH: "maxLength";
31
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
32
+ /** @deprecated Use MAX_DECIMAL_PLACES instead. This key mapped to the wrong string value and never matched the backend. */
29
33
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
30
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
34
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
31
35
  export type SerializedFieldConstraint = {
32
36
  'Type': FieldConstraintType;
33
37
  'Details'?: UnsafeJsonSerializableOrUndefined;
@@ -43,8 +47,10 @@ export declare const isSerializedFieldConstraint: (subject: unknown) => subject
43
47
  readonly NO_WHITESPACE: "noWhitespace";
44
48
  readonly UNIQUE_EDIT: "uniqueEditType";
45
49
  readonly MAX_LENGTH: "maxLength";
50
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
51
+ /** @deprecated Use MAX_DECIMAL_PLACES instead. This key mapped to the wrong string value and never matched the backend. */
46
52
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
47
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
53
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
48
54
  Details: (x: unknown) => x is any | undefined;
49
55
  Reason: (x: unknown) => x is string | null | undefined;
50
56
  }>;
@@ -69,8 +75,10 @@ export declare const isSerializedFieldDefinition: (subject: unknown) => subject
69
75
  readonly NO_WHITESPACE: "noWhitespace";
70
76
  readonly UNIQUE_EDIT: "uniqueEditType";
71
77
  readonly MAX_LENGTH: "maxLength";
78
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
79
+ /** @deprecated Use MAX_DECIMAL_PLACES instead. This key mapped to the wrong string value and never matched the backend. */
72
80
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
73
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
81
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
74
82
  Details: (x: unknown) => x is any | undefined;
75
83
  Reason: (x: unknown) => x is string | null | undefined;
76
84
  }>[] | undefined;
@@ -17,6 +17,8 @@ exports.FieldConstraintType = {
17
17
  NO_WHITESPACE: 'noWhitespace',
18
18
  UNIQUE_EDIT: 'uniqueEditType',
19
19
  MAX_LENGTH: 'maxLength',
20
+ MAX_DECIMAL_PLACES: 'maxDecimalPlaces',
21
+ /** @deprecated Use MAX_DECIMAL_PLACES instead. This key mapped to the wrong string value and never matched the backend. */
20
22
  MAX_DECIMAL_LENGTH: 'maxDecimalLength',
21
23
  };
22
24
  exports.isFieldConstraintType = (0, validators_1.enumValidator)(exports.FieldConstraintType);
package/core/defer.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export interface DeferredPromise<T> extends Promise<T> {
1
+ export interface DeferredPromise<T = void> extends Promise<T> {
2
2
  resolve: (p1: T | PromiseLike<T>) => any;
3
3
  reject: (p1?: any) => any;
4
4
  promise: Promise<T>;
@@ -108,8 +108,12 @@ function generateNullish() {
108
108
  function generatePartialRecord(keyGenerator, valueGenerator) {
109
109
  return function () {
110
110
  const result = {};
111
- for (const { key, value } of (0, iterable_1.zipHoldShorter)({ key: keyGenerator(), value: valueGenerator() })) {
112
- result[key] = value;
111
+ const keys = Array.from(keyGenerator());
112
+ const values = Array.from(valueGenerator());
113
+ if (keys.length > 0 && values.length > 0) {
114
+ for (const { key, value } of (0, iterable_1.zipHoldShorter)({ key: keys, value: values })) {
115
+ result[key] = value;
116
+ }
113
117
  }
114
118
  return [{}, result];
115
119
  };
@@ -118,8 +122,12 @@ function generatePartialRecord(keyGenerator, valueGenerator) {
118
122
  function generateMapEntries(keyGenerator, valueGenerator) {
119
123
  return function () {
120
124
  const result = [];
121
- for (const { key, value } of (0, iterable_1.zipHoldShorter)({ key: keyGenerator(), value: valueGenerator() })) {
122
- result.push([key, value]);
125
+ const keys = Array.from(keyGenerator());
126
+ const values = Array.from(valueGenerator());
127
+ if (keys.length > 0 && values.length > 0) {
128
+ for (const { key, value } of (0, iterable_1.zipHoldShorter)({ key: keys, value: values })) {
129
+ result.push([key, value]);
130
+ }
123
131
  }
124
132
  return [[], result];
125
133
  };
@@ -177,8 +177,9 @@ export declare const isSerializedExtensionCardFieldDefinition: (subject: unknown
177
177
  readonly NO_WHITESPACE: "noWhitespace";
178
178
  readonly UNIQUE_EDIT: "uniqueEditType";
179
179
  readonly MAX_LENGTH: "maxLength";
180
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
180
181
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
181
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
182
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
182
183
  Details: (x: unknown) => x is any | undefined;
183
184
  Reason: (x: unknown) => x is string | null | undefined;
184
185
  }>[] | undefined;
@@ -224,8 +225,9 @@ export declare const isSerializedExtensionCardFieldsGroup: (subject: unknown) =>
224
225
  readonly NO_WHITESPACE: "noWhitespace";
225
226
  readonly UNIQUE_EDIT: "uniqueEditType";
226
227
  readonly MAX_LENGTH: "maxLength";
228
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
227
229
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
228
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
230
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
229
231
  Details: (x: unknown) => x is any | undefined;
230
232
  Reason: (x: unknown) => x is string | null | undefined;
231
233
  }>[] | undefined;
@@ -259,8 +261,9 @@ export declare const isSerializedExtensionCardFieldsGroupArray: (val: unknown) =
259
261
  readonly NO_WHITESPACE: "noWhitespace";
260
262
  readonly UNIQUE_EDIT: "uniqueEditType";
261
263
  readonly MAX_LENGTH: "maxLength";
264
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
262
265
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
263
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
266
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
264
267
  Details: (x: unknown) => x is any | undefined;
265
268
  Reason: (x: unknown) => x is string | null | undefined;
266
269
  }>[] | undefined;
@@ -41,13 +41,19 @@ export interface MaxLengthConstraintDefinition {
41
41
  reason?: string | undefined;
42
42
  }
43
43
  export interface MaxDecimalPlacesConstraintDefinition {
44
+ type: typeof FieldConstraintType.MAX_DECIMAL_PLACES;
45
+ value: number;
46
+ reason?: string | undefined;
47
+ }
48
+ /** @deprecated Use MaxDecimalPlacesConstraintDefinition instead. */
49
+ export interface MaxDecimalLengthConstraintDefinition {
44
50
  type: typeof FieldConstraintType.MAX_DECIMAL_LENGTH;
45
51
  value: number;
46
52
  reason?: string | undefined;
47
53
  }
48
- export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition | MaxDecimalPlacesConstraintDefinition;
54
+ export type FieldConstraintDefinition = RequiredFieldConstraintDefinition | LockedFieldConstraintDefinition | MinValueFieldConstraintDefinition | MaxValueFieldConstraintDefinition | SingleLineFieldConstraintDefinition | NoWhitespaceFieldConstraintDefinition | UniqueEditFieldConstraintDefinition | MaxLengthConstraintDefinition | MaxDecimalPlacesConstraintDefinition | MaxDecimalLengthConstraintDefinition;
49
55
  export declare function createFieldConstraintDefinition(type: FieldConstraintType, value?: number, reason?: string): FieldConstraintDefinition;
50
- export declare function numericFieldConstraintValidator(val: unknown): val is typeof FieldConstraintType.MIN_VALUE | typeof FieldConstraintType.MAX_VALUE | typeof FieldConstraintType.MAX_LENGTH | typeof FieldConstraintType.MAX_DECIMAL_LENGTH;
56
+ export declare function numericFieldConstraintValidator(val: unknown): val is typeof FieldConstraintType.MIN_VALUE | typeof FieldConstraintType.MAX_VALUE | typeof FieldConstraintType.MAX_LENGTH | typeof FieldConstraintType.MAX_DECIMAL_PLACES | typeof FieldConstraintType.MAX_DECIMAL_LENGTH;
51
57
  export declare const isFieldConstraintDefinition: (x: unknown) => x is import("..").DestructureGuardedTypeObj<{
52
58
  type: (x: unknown) => x is {} extends {
53
59
  readonly REQUIRED: "required";
@@ -58,8 +64,9 @@ export declare const isFieldConstraintDefinition: (x: unknown) => x is import(".
58
64
  readonly NO_WHITESPACE: "noWhitespace";
59
65
  readonly UNIQUE_EDIT: "uniqueEditType";
60
66
  readonly MAX_LENGTH: "maxLength";
67
+ readonly MAX_DECIMAL_PLACES: "maxDecimalPlaces";
61
68
  readonly MAX_DECIMAL_LENGTH: "maxDecimalLength";
62
- } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalLength";
69
+ } ? never : "locked" | "required" | "minValue" | "maxValue" | "singleLineOnly" | "noWhitespace" | "uniqueEditType" | "maxLength" | "maxDecimalPlaces" | "maxDecimalLength";
63
70
  }> & (import("..").DestructureGuardedTypeObj<{
64
71
  type: typeof numericFieldConstraintValidator;
65
72
  value: typeof isNumber;
@@ -16,6 +16,7 @@ function createFieldConstraintDefinition(type, value, reason) {
16
16
  case serializedfielddefinition_1.FieldConstraintType.MIN_VALUE:
17
17
  case serializedfielddefinition_1.FieldConstraintType.MAX_VALUE:
18
18
  case serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH:
19
+ case serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_PLACES:
19
20
  case serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_LENGTH:
20
21
  if (value === undefined) {
21
22
  throw new Error('Invalid constraint value');
@@ -36,6 +37,7 @@ function numericFieldConstraintValidator(val) {
36
37
  return (val === serializedfielddefinition_1.FieldConstraintType.MIN_VALUE ||
37
38
  val === serializedfielddefinition_1.FieldConstraintType.MAX_VALUE ||
38
39
  val === serializedfielddefinition_1.FieldConstraintType.MAX_LENGTH ||
40
+ val === serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_PLACES ||
39
41
  val === serializedfielddefinition_1.FieldConstraintType.MAX_DECIMAL_LENGTH);
40
42
  }
41
43
  exports.isFieldConstraintDefinition = (0, validators_1.both)((0, validators_1.objectValidator)({
@@ -76,7 +76,7 @@ export declare class ItemsPatchInexhaustive {
76
76
  itemsDeleted?: string[] | undefined;
77
77
  errors?: Map<string, SerializedLucidDictionary> | undefined;
78
78
  fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined;
79
- private readonly _brand;
79
+ readonly _brand: typeof ItemsPatchInexhaustive;
80
80
  constructor(
81
81
  /**
82
82
  * Items to be added or changed in the collection. Mapping from item serialized primary key to
@@ -93,7 +93,7 @@ export declare class ItemsPatchExhaustive {
93
93
  fieldNamesChanged?: Map<string, string | null> | undefined;
94
94
  errors?: Map<string, SerializedLucidDictionary> | undefined;
95
95
  fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined;
96
- private readonly _brand;
96
+ readonly _brand: typeof ItemsPatchExhaustive;
97
97
  constructor(items: Map<string, SerializedFields>, rekeyingMap?: Map<string, string | null> | undefined, fieldNamesChanged?: Map<string, string | null> | undefined, errors?: Map<string, SerializedLucidDictionary> | undefined, fieldConstraintsPerItem?: Map<string, Map<string, FieldConstraintDefinition[]>> | undefined);
98
98
  }
99
99
  /** The anonymous type is kept for backward compatibility; use ItemsPatchInexhaustive instead. */
@@ -20,7 +20,7 @@ class TableCellProxy {
20
20
  return this.table.textStyles.get(`Cell_${this.row},${this.column}`);
21
21
  }
22
22
  setTextStyle(style) {
23
- this.table.textStyles.set(`Cell_${this.row},${this.column}`, style);
23
+ void this.table.textStyles.set(`Cell_${this.row},${this.column}`, style);
24
24
  }
25
25
  setFill(fill) {
26
26
  this.table.properties.set(`CellFill_${this.row},${this.column}`, (0, fillcolor_1.serializeSimpleFill)(fill));
@@ -5,10 +5,9 @@ import { type ConditionDefinition, type EffectDefinition, type RuleDefinition }
5
5
  import { DocumentElementProxy } from './documentelementproxy';
6
6
  export declare class RuleCondition {
7
7
  readonly rule: RuleProxy;
8
- private readonly client;
9
8
  readonly key: string;
10
9
  private definition;
11
- constructor(rule: RuleProxy, client: EditorClient, key: string);
10
+ constructor(rule: RuleProxy, key: string);
12
11
  /** What kind of condition is this? e.g. a formula evaluation, checking for non-empty text, etc. */
13
12
  readonly type: import("../..").ConditionType;
14
13
  /**
@@ -39,10 +38,9 @@ export declare class RuleCondition {
39
38
  }
40
39
  export declare class RuleEffect {
41
40
  readonly rule: RuleProxy;
42
- private readonly client;
43
41
  readonly key: string;
44
42
  private definition;
45
- constructor(rule: RuleProxy, client: EditorClient, key: string);
43
+ constructor(rule: RuleProxy, key: string);
46
44
  readonly conditions: MapProxy<string, RuleCondition>;
47
45
  /** How multiple conditions are combined (AND vs OR) */
48
46
  readonly combination: import("../..").ConditionCombination;
@@ -7,9 +7,8 @@ const mapproxy_1 = require("../mapproxy");
7
7
  const ruledefinition_1 = require("../ruledefinition");
8
8
  const documentelementproxy_1 = require("./documentelementproxy");
9
9
  class RuleCondition {
10
- constructor(rule, client, key) {
10
+ constructor(rule, key) {
11
11
  this.rule = rule;
12
- this.client = client;
13
12
  this.key = key;
14
13
  this.definition = this.rule.properties.get(this.key);
15
14
  /** What kind of condition is this? e.g. a formula evaluation, checking for non-empty text, etc. */
@@ -46,12 +45,11 @@ class RuleCondition {
46
45
  }
47
46
  exports.RuleCondition = RuleCondition;
48
47
  class RuleEffect {
49
- constructor(rule, client, key) {
48
+ constructor(rule, key) {
50
49
  this.rule = rule;
51
- this.client = client;
52
50
  this.key = key;
53
51
  this.definition = this.rule.properties.get(this.key);
54
- this.conditions = new mapproxy_1.MapProxy(() => this.definition['ConditionOrder'].map((order) => 'Condition_' + order), (key) => new RuleCondition(this.rule, this.client, key));
52
+ this.conditions = new mapproxy_1.MapProxy(() => this.definition['ConditionOrder'].map((order) => 'Condition_' + order), (key) => new RuleCondition(this.rule, key));
55
53
  /** How multiple conditions are combined (AND vs OR) */
56
54
  this.combination = this.definition['Combination'];
57
55
  /** What kind of effect is displayed? Formatting vs. icons vs. dynamic stencil, etc. */
@@ -101,7 +99,7 @@ class RuleProxy extends documentelementproxy_1.DocumentElementProxy {
101
99
  constructor(id, client) {
102
100
  super(id, client);
103
101
  this.id = id;
104
- this.effects = new mapproxy_1.MapProxy(() => this.properties.get('EffectOrder').map((order) => 'Effect_' + order), (key) => new RuleEffect(this, this.client, key));
102
+ this.effects = new mapproxy_1.MapProxy(() => this.properties.get('EffectOrder').map((order) => 'Effect_' + order), (key) => new RuleEffect(this, key));
105
103
  }
106
104
  getName() {
107
105
  return this.properties.get('Name');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.454",
3
+ "version": "0.0.456",
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.js CHANGED
@@ -60,7 +60,7 @@ class Viewport {
60
60
  * @param page The page to view
61
61
  */
62
62
  setCurrentPage(page) {
63
- this.client.sendCommand(commandtypes_1.CommandName.SetCurrentPage, page.id);
63
+ void this.client.sendCommand(commandtypes_1.CommandName.SetCurrentPage, page.id);
64
64
  }
65
65
  /**
66
66
  * @returns the box for the current viewport location
@@ -77,7 +77,7 @@ class Viewport {
77
77
  const bb = (0, math_1.combinedBoundingBox)(items.map((e) => e.getBoundingBox()));
78
78
  if (bb && items[0]) {
79
79
  //TODO: A reasonable max zoom level (e.g. 200%)
80
- this.client.sendCommand(commandtypes_1.CommandName.AnimateViewport, {
80
+ void this.client.sendCommand(commandtypes_1.CommandName.AnimateViewport, {
81
81
  'bb': (0, math_1.padBox)(bb, 80),
82
82
  'p': items[0].getPage().id,
83
83
  });