lucid-extension-sdk
Advanced tools
Comparing version 0.0.120 to 0.0.121
{ | ||
"name": "lucid-extension-sdk", | ||
"version": "0.0.120", | ||
"version": "0.0.121", | ||
"description": "Utility classes for writing Lucid Software editor extensions", | ||
@@ -5,0 +5,0 @@ "main": "sdk/index.js", |
@@ -11,2 +11,3 @@ import { SerializedFieldTypeDefinition } from './core/data/fieldtypedefinition/fieldtypedefinition'; | ||
import { SerializedLineTextAreaPositioning } from './document/linetextareapositioning'; | ||
import { TextStyle } from './document/text/textstyle'; | ||
import { Box, Point } from './math'; | ||
@@ -63,2 +64,3 @@ import { MenuLocation, MenuType } from './ui/menu'; | ||
GetShapeData = "gsd", | ||
GetTextStyle = "gts", | ||
HideModal = "hm", | ||
@@ -101,2 +103,3 @@ HidePanel = "hp", | ||
SetText = "st", | ||
SetTextStyle = "sts", | ||
ShowModal = "sm", | ||
@@ -283,2 +286,6 @@ ShowPanel = "spn", | ||
}; | ||
[CommandName.GetTextStyle]: { | ||
query: GetTextStyleQuery; | ||
result: GetTextStyleResult; | ||
}; | ||
[CommandName.HideModal]: { | ||
@@ -432,2 +439,6 @@ query: HideModalQuery; | ||
}; | ||
[CommandName.SetTextStyle]: { | ||
query: SetTextStyleQuery; | ||
result: SetTextStyleResult; | ||
}; | ||
[CommandName.ShowModal]: { | ||
@@ -835,2 +846,9 @@ query: ShowModalQuery; | ||
export declare type GetShapeDataResult = SerializedFieldType | SerializedDataError; | ||
export declare type GetTextStyleQuery = { | ||
/** ID of the element to get text style from */ | ||
'id': string; | ||
/** Name of the text area to get text style from */ | ||
'n': string; | ||
}; | ||
export declare type GetTextStyleResult = TextStyle; | ||
export declare type HideModalQuery = { | ||
@@ -1072,2 +1090,11 @@ /** Name of the modal's action for receiving events, i.e. ShowModalQuery['n'] */ | ||
export declare type SetTextResult = undefined; | ||
export declare type SetTextStyleQuery = { | ||
/** ID of the element to set text style on */ | ||
'id': string; | ||
/** Name of the text area to set text style on */ | ||
'n': string; | ||
/** Text styles to set */ | ||
's': Partial<TextStyle>; | ||
}; | ||
export declare type SetTextStyleResult = Promise<undefined>; | ||
export declare type ShowModalQuery = { | ||
@@ -1074,0 +1101,0 @@ /** Name of the modal's action for receiving events; generated automatically by Modal base class */ |
@@ -45,2 +45,3 @@ "use strict"; | ||
["gsd" /* CommandName.GetShapeData */, 'GetShapeData'], | ||
["gts" /* CommandName.GetTextStyle */, 'GetTextStyle'], | ||
["hm" /* CommandName.HideModal */, 'HideModal'], | ||
@@ -81,2 +82,3 @@ ["hp" /* CommandName.HidePanel */, 'HidePanel'], | ||
["ssd" /* CommandName.SetShapeData */, 'SetShapeData'], | ||
["sts" /* CommandName.SetTextStyle */, 'SetTextStyle'], | ||
["sm" /* CommandName.ShowModal */, 'ShowModal'], | ||
@@ -83,0 +85,0 @@ ["spsm" /* CommandName.ShowPackageSettingsModal */, 'ShowPackageSettingsModal'], |
@@ -73,2 +73,10 @@ import { isNumber, isString } from '../checks'; | ||
/** | ||
* Creates a validator which tests if the target is an object | ||
* and if the structure of the object matches the structure of the passed-in | ||
* validator object, but with every entry being optional. | ||
*/ | ||
export declare function partialObjectValidator<T extends { | ||
[key: string]: (p1: unknown) => p1 is unknown; | ||
}>(validatorStructure: T): (subject: unknown) => subject is Partial<DestructureGuardedTypeObj<T>>; | ||
/** | ||
* Similar to {@link objectValidator}, but if the object has any non-undefined keys, they must also be present in the validator structure. | ||
@@ -75,0 +83,0 @@ * This is useful for things where extra data is unwanted, like Property serialization. |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0; | ||
exports.asAssertion = exports.validatorWithMessage = exports.minLengthValidator = exports.maxLengthValidator = exports.isDate = exports.isPositiveNumber = exports.isSize = exports.isPanelSize = exports.isBoundingBox = exports.isPointLike = exports.isOpacity = exports.isTrue = exports.isFlag = exports.isRestrictions = exports.isStringOrNegativeOne = exports.isBooleanOrEmptyString = exports.isNumberOrEmptyString = exports.isSet = exports.propertyValidator = exports.exclude = exports.both = exports.either = exports.isNullOption = exports.nullableOption = exports.option = exports.nullable = exports.objectOfValidator = exports.recordValidator = exports.strictObjectValidator = exports.partialObjectValidator = exports.objectValidator = exports.mapValidator = exports.someValidator = exports.someValue = exports.tupleValidator = exports.arrayValidator = exports.rangeValidator = exports.enumValidator = exports.stringEnumValidator = void 0; | ||
const checks_1 = require("../checks"); | ||
@@ -149,2 +149,20 @@ const object_1 = require("../object"); | ||
/** | ||
* Creates a validator which tests if the target is an object | ||
* and if the structure of the object matches the structure of the passed-in | ||
* validator object, but with every entry being optional. | ||
*/ | ||
function partialObjectValidator(validatorStructure) { | ||
return (subject) => { | ||
if ((0, checks_1.isArray)(subject) || !(0, checks_1.isObject)(subject)) { | ||
return false; | ||
} | ||
else { | ||
return (0, object_1.objectEvery)(validatorStructure, (validator, key) => { | ||
return subject[key] === undefined || validator(subject[key]); | ||
}); | ||
} | ||
}; | ||
} | ||
exports.partialObjectValidator = partialObjectValidator; | ||
/** | ||
* Similar to {@link objectValidator}, but if the object has any non-undefined keys, they must also be present in the validator structure. | ||
@@ -151,0 +169,0 @@ * This is useful for things where extra data is unwanted, like Property serialization. |
@@ -6,2 +6,3 @@ import { LinearOffsetType } from '../core/offsettype'; | ||
import { WriteableMapProxy } from './mapproxy'; | ||
import { TextStyle } from './text/textstyle'; | ||
/** | ||
@@ -20,4 +21,8 @@ * A block, line, or group on a page of the current document. | ||
*/ | ||
readonly textAreas: WriteableMapProxy<string, string>; | ||
readonly textAreas: WriteableMapProxy<string, string, undefined, string>; | ||
/** | ||
* The text style in each of the text areas on this item, organized by text area name. | ||
*/ | ||
readonly textStyles: WriteableMapProxy<string, TextStyle, Promise<undefined>, Partial<TextStyle>>; | ||
/** | ||
* @returns The bounding box of this item relative to its containing page. As pages may change size | ||
@@ -24,0 +29,0 @@ * to fit the content on them, note that these coordinates may be negative or very large. |
@@ -30,2 +30,13 @@ "use strict"; | ||
})); | ||
/** | ||
* The text style in each of the text areas on this item, organized by text area name. | ||
*/ | ||
this.textStyles = new mapproxy_1.WriteableMapProxy(() => this.textAreas.keys(), (name) => this.client.sendCommand("gts" /* CommandName.GetTextStyle */, { | ||
'id': this.id, | ||
'n': name, | ||
}), (name, style) => this.client.sendCommand("sts" /* CommandName.SetTextStyle */, { | ||
'id': this.id, | ||
'n': name, | ||
's': style, | ||
})); | ||
} | ||
@@ -32,0 +43,0 @@ /** |
@@ -18,6 +18,6 @@ /** | ||
} | ||
export declare class WriteableMapProxy<KEY, VALUE> extends MapProxy<KEY, VALUE> { | ||
export declare class WriteableMapProxy<KEY, VALUE, WRITERETURN, WRITEVALUE = VALUE> extends MapProxy<KEY, VALUE> { | ||
private readonly setter; | ||
constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE, setter: (key: KEY, val: VALUE, options?: SetterOptions) => void); | ||
set(key: KEY, value: VALUE, options?: SetterOptions): void; | ||
constructor(getKeys: () => KEY[], getItem: (key: KEY) => VALUE, setter: (key: KEY, val: WRITEVALUE, options?: SetterOptions) => WRITERETURN); | ||
set(key: KEY, value: WRITEVALUE, options?: SetterOptions): WRITERETURN; | ||
} | ||
@@ -24,0 +24,0 @@ export interface SetterOptions { |
@@ -62,5 +62,5 @@ "use strict"; | ||
set(key, value, options = {}) { | ||
this.setter(key, value, options); | ||
return this.setter(key, value, options); | ||
} | ||
} | ||
exports.WriteableMapProxy = WriteableMapProxy; |
@@ -14,3 +14,3 @@ import { EditorClient } from '../editorclient'; | ||
*/ | ||
readonly properties: WriteableMapProxy<string, import("..").JsonSerializable>; | ||
readonly properties: WriteableMapProxy<string, import("..").JsonSerializable, void, import("..").JsonSerializable>; | ||
/** | ||
@@ -17,0 +17,0 @@ * |
@@ -9,3 +9,3 @@ import { SerializedFieldType } from '../core/data/serializedfield/serializedfields'; | ||
*/ | ||
export declare class ShapeDataProxy extends WriteableMapProxy<string, SerializedFieldType | SerializedDataError> { | ||
export declare class ShapeDataProxy extends WriteableMapProxy<string, SerializedFieldType | SerializedDataError, void> { | ||
readonly id: string | undefined; | ||
@@ -12,0 +12,0 @@ protected readonly client: EditorClient; |
@@ -90,2 +90,3 @@ export * from './commandtypes'; | ||
export * from './document/shapedataproxy'; | ||
export * from './document/text/textstyle'; | ||
export * from './editorclient'; | ||
@@ -92,0 +93,0 @@ export * from './index'; |
@@ -106,2 +106,3 @@ "use strict"; | ||
__exportStar(require("./document/shapedataproxy"), exports); | ||
__exportStar(require("./document/text/textstyle"), exports); | ||
__exportStar(require("./editorclient"), exports); | ||
@@ -108,0 +109,0 @@ __exportStar(require("./index"), exports); |
505855
220
11695