diff --git a/sample.js b/sample.js index 97afcee..cc9c5db 100644 --- a/sample.js +++ b/sample.js @@ -1,6 +1,5 @@ const {Text, Ellipse, Color, RootNode} = require("scenegraph"); const clipboard = require("clipboard"); -const application = require("application"); const shell = require("uxp").shell; const fs = require("uxp").storage.localFileSystem; @@ -19,9 +18,16 @@ async function test(selection, documentRoot) { } }); const tempFolder = await fs.getTemporaryFolder(); - const newFile = await tempFolder.createEntry("tempfile.txt", {overwrite: true}); - newFile.write("Hello, world!"); + const newFile = await tempFolder.createFile("tempfile.txt", {overwrite: true}); + await newFile.write("Hello, world!"); await newFile.moveTo(tempFolder, {overwrite: true}); + + const anotherFile = await tempFolder.getEntry('tempfile.txt'); + if (anotherFile.isFile) { + anotherFile.write("Good day"); + } else if (anotherFile.isFolder) { + console.log("That's a folder. It shouldn't be a folder. What have you done?") + } } module.exports = { diff --git a/types/application.d.ts b/types/application.d.ts index bf44d17..c5ceb24 100644 --- a/types/application.d.ts +++ b/types/application.d.ts @@ -61,22 +61,22 @@ declare class application { * @param renditions List of renditions to generate * @return Promise, string> - Promise which is fulfilled with an array of RenditionResults (pointing to the same outputFiles that were originally passed in, or rejected with an error string if one or more renditions failed for any reason. */ - public static createRenditions(renditions: RenditionSettings[]): Promise; + static createRenditions(renditions: RenditionSettings[]): Promise; /** * Adobe XD version number in the form "major.minor.patch.build" */ - public static readonly version: string; + static readonly version: string; /** * Current language the application UI is using. This may not equal the user's OS locale setting: it is the closest locale supported by XD - use this when you want your plugin's UI to be consistent with XD's UI. Specifies language only, with no region info (e.g. "fr", not "fr_FR"). */ - public static readonly appLanguage: string; + static readonly appLanguage: string; /** * User's OS-wide locale setting. May not match the XD UI, since XD does not support all world languages. Includes both language and region (e.g. "fr_CA" or "en_US"). */ - public static readonly systemLocale: string; + static readonly systemLocale: string; } export = application; diff --git a/types/assets.d.ts b/types/assets.d.ts index 822acdf..f24574b 100644 --- a/types/assets.d.ts +++ b/types/assets.d.ts @@ -127,7 +127,7 @@ declare module assets { * allColors = assets.colors.get(); * */ - public static get(): Array; + static get(): Array; /** * Add color/gradient assets to the collection. @@ -136,7 +136,7 @@ declare module assets { * @param colorAssets The color assets * @returns {number} number of assets added (may be less than requested if duplicates already exist) */ - public static add(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array): number; + static add(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array): number; /** * Delete color/gradient assets from the collection. @@ -146,7 +146,7 @@ declare module assets { * @param colorAssets The color assets * @returns {number} number of assets deleted (may be less than requested if some didn't exist) */ - public static delete(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array): number; + static delete(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array): number; } /** @@ -163,7 +163,7 @@ declare module assets { * allCharacterStyles = assets.characterStyles.get(); * */ - public static get(): Array; + static get(): Array; /** * Add one or more character style assets to the collection. @@ -173,7 +173,7 @@ declare module assets { * @param charStyleAssets The character style assets * @returns {number} number of assets added (may be less than requested if duplicates already exist) */ - public static add(charStyleAssets: CharacterStyleAsset | Array): number; + static add(charStyleAssets: CharacterStyleAsset | Array): number; /** * Delete one or more character style assets from the collection. @@ -185,7 +185,7 @@ declare module assets { * @returns {number} number of assets deleted (may be less than requested if some didn't exist) * @param charStyleAssets The character styles */ - public static delete(charStyleAssets: CharacterStyleAsset | Array): number; + static delete(charStyleAssets: CharacterStyleAsset | Array): number; } } diff --git a/types/clipboard.d.ts b/types/clipboard.d.ts index da6c321..01a9fcf 100644 --- a/types/clipboard.d.ts +++ b/types/clipboard.d.ts @@ -6,7 +6,7 @@ declare class clipboard { * Write plain text to the clipboard. * @param text Will be automatically converted to string if a different type is passed */ - public static copyText(text: string | any): void; + static copyText(text: string | any): void; } export = clipboard; diff --git a/types/commands.d.ts b/types/commands.d.ts index c8201fa..e813a82 100644 --- a/types/commands.d.ts +++ b/types/commands.d.ts @@ -5,22 +5,22 @@ declare class commands { /** * Wraps the selected objects in a Group, leaving the Group selected afterward. Equivalent to Object > Group in the UI. */ - public static group(): void; + static group(): void; /** * Ungroups any of the selected objects that are ungroupable containers (Group, SymbolInstance, RepeatGrid, etc.). Equivalent to _Object > Ungroup_. */ - public static ungroup(): void; + static ungroup(): void; /** * Creates a masked Group from the selected objects, using the object that is highest in the z order as the mask shape. The mask shape must be a leaf node or Boolean Group. Equivalent to Object > Mask With Shape. */ - public static createMaskGroup(): void; + static createMaskGroup(): void; /** * Converts each selected object to a Path with the exact same visual appearance. Only applies to leaf nodes and Boolean Groups. Equivalent to Object > Path > Convert to Path. */ - public static convertToPath(): void; + static convertToPath(): void; /** * Duplicates all selected objects, leaving the duplicates selected afterward. @@ -30,83 +30,83 @@ declare class commands { * * Edit > Duplicate */ - public static duplicate(): void; + static duplicate(): void; /** * Brings selected objects to the front of the z order. Equivalent to Object > Arrange > Bring to Front. */ - public static bringToFront(): void; + static bringToFront(): void; /** * Brings each selected object one step closer to the front of the z order. Equivalent to Object > Arrange > Bring Forward. */ - public static bringForward(): void; + static bringForward(): void; /** * Sends selected objects to the back of the z order. Equivalent to Object > Arrange > Send to Back. */ - public static sendToBack(): void; + static sendToBack(): void; /** * Sends each selected object one step closer to the back of the z order. Equivalent to Object > Arrange > Send Backward. */ - public static sendBackward(): void; + static sendBackward(): void; /** * Aligns all selected objects flush left. Equivalent to Object > Align > Left. */ - public static alignLeft(): void; + static alignLeft(): void; /** * Aligns all selected objects flush right. Equivalent to Object > Align > Right. */ - public static alignRight(): void; + static alignRight(): void; /** * Aligns all selected objects along their horizontal centerlines. Equivalent to Object > Align > Center (Horizontally). */ - public static alignHorizontalCenter(): void; + static alignHorizontalCenter(): void; /** * Aligns all selected objects flush top. Equivalent to Object > Align > Top. */ - public static alignTop(): void; + static alignTop(): void; /** * Aligns all selected objects flush bottom. Equivalent to Object > Align > Bottom. */ - public static alignBottom(): void; + static alignBottom(): void; /** * Aligns all selected objects along their vertical centerlines. Equivalent to Object > Align > Center (Vertically). */ - public static alignVerticalCenter(): void; + static alignVerticalCenter(): void; /** * Distributes all selected objects evenly along the X axis. Equivalent to Object > Distribute > Horizontally. */ - public static distributeHorizontal(): void; + static distributeHorizontal(): void; /** * Distributes all selected objects evenly along the Y axis. Equivalent to Object > Distribute > Vertically. */ - public static distributeVertical(): void; + static distributeVertical(): void; /** * Shifts all selected objects and their content so they align crisply with the pixel grid. Equivalent to Object > Align to Pixel Grid. */ - public static alignToPixelGrid(): void; + static alignToPixelGrid(): void; // /** //* Flips the object horizontally. Some objects such as Symbols cannot be flipped. Equivalent to Object > Flip > Horizontally. //*/ - //public static filpHorizontal(): void; + //static filpHorizontal(): void; // // /** // * Flips the object vertically. Some objects such as Symbols cannot be flipped. Equivalent to Object > Flip > Vertically. //*/ - //public static flipVertical(): void; + //static flipVertical(): void; } export = commands; diff --git a/types/index.d.ts b/types/index.d.ts index 5b2d442..611c68b 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -15,35 +15,35 @@ declare global { * Represents the children of a scenenode. Typically accessed via the SceneNode.children property. */ class SceneNodeList { - public items: SceneNode[]; - public readonly length: number; + items: SceneNode[]; + readonly length: number; - public forEach( + forEach( callback: (sceneNode: SceneNode, index: number) => void, thisArg?: object ): void; - public forEachRight( + forEachRight( callback: (sceneNode: SceneNode, index: number) => void, thisArg?: object ): void; - public filter( + filter( callback: (sceneNode: SceneNode, index: number) => boolean, thisArg?: object ): Array; - public map( + map( callback: (sceneNode: SceneNode, index: number) => any, thisArg?: object ): Array; - public some( + some( callback: (sceneNode: SceneNode, index: number) => boolean, thisArg?: object ): boolean; - public at(index: number): SceneNode | null; + at(index: number): SceneNode | null; } /** @@ -106,6 +106,6 @@ declare global { * Opens the url in an the system browser. * @param url The url which should be opened */ - public openExternal(url: string); + openExternal(url: string); } } diff --git a/types/interactions.d.ts b/types/interactions.d.ts index 8c472b9..c2c665e 100644 --- a/types/interactions.d.ts +++ b/types/interactions.d.ts @@ -31,7 +31,7 @@ declare class interactions { * The starting Artboard seen when the interactive prototype is launched. * @see Artboard.isHomeArtboard */ - public static readonly homeArtboard?: Artboard; + static readonly homeArtboard?: Artboard; /** * Returns a collection of *all* interactions across the entire document, grouped by triggering scenenode. Each entry in this array specifies a `triggerNode` and the result of getting [`triggerNode.triggeredInteractions`](./scenegraph.md#SceneNode-triggeredInteractions). @@ -40,7 +40,7 @@ declare class interactions { * * Note: currently, this API excludes all of the document's keyboard/gamepad interactions. */ - public static readonly allInteractions: Array<{ triggerNode: SceneNode, interactions: Array }>; + static readonly allInteractions: Array<{ triggerNode: SceneNode, interactions: Array }>; } /** diff --git a/types/scenegraph.d.ts b/types/scenegraph.d.ts index fb654b1..e5042b7 100644 --- a/types/scenegraph.d.ts +++ b/types/scenegraph.d.ts @@ -29,18 +29,18 @@ declare class Matrix { * @param e * @param f */ - public constructor(a: number, b: number, c: number, d: number, e: number, f: number); + constructor(a: number, b: number, c: number, d: number, e: number, f: number); /** * Copies another matrix's values into this matrix. * @param otherMatrix The matrix to copy values from. */ - public setFrom(otherMatrix: Matrix); + setFrom(otherMatrix: Matrix); /** * Returns a copy of the matrix */ - public clone(): Matrix; + clone(): Matrix; /** * Multiplies a passed affine transform to the right: this * M. The result effectively applies the transform of the passed in matrix first, followed by the transform of this matrix second. Modifies this matrix object and also returns it so calls can be chained. @@ -51,13 +51,13 @@ declare class Matrix { * @param e The e component of an affine transform. * @param f The f component of an affine transform. */ - public add(aOrOtherMatrix: number, b: number, c: number, d: number, e: number, f: number); + add(aOrOtherMatrix: number, b: number, c: number, d: number, e: number, f: number); /** * Multiplies a passed affine transform to the right: this * M. The result effectively applies the transform of the passed in matrix first, followed by the transform of this matrix second. Modifies this matrix object and also returns it so calls can be chained. * @param aOrOtherMatrix A Matrix or the a component of an affine transform. */ - public add(aOrOtherMatrix: Matrix); + add(aOrOtherMatrix: Matrix); /** * Multiplies a passed affine transform to the left: M * this. The result effectively applies the transform of this matrix first, followed by the transform of the passed in matrix second. Modifies this matrix object and also returns it so calls can be chained. @@ -68,25 +68,25 @@ declare class Matrix { * @param e The e component of an affine transform. * @param f The f component of an affine transform. */ - public multLeft(aOrOtherMatrix: number, b: number, c: number, d: number, e: number, f: number); + multLeft(aOrOtherMatrix: number, b: number, c: number, d: number, e: number, f: number); /** * Multiplies a passed affine transform to the left: M * this. The result effectively applies the transform of this matrix first, followed by the transform of the passed in matrix second. Modifies this matrix object and also returns it so calls can be chained. * @param aOrOtherMatrix A Matrix or the a component of an affine transform. */ - public multLeft(aOrOtherMatrix: Matrix); + multLeft(aOrOtherMatrix: Matrix); /** * Returns an inverted version of the matrix. Returns a brand new matrix - does not modify this matrix object. */ - public invert(): Matrix; + invert(): Matrix; /** * Applies translation before the current transform of this matrix, as if using the add() method. Modifies this matrix object and also returns it so calls can be chained. * @param tx horizontal offset distance * @param ty vertical offset distance */ - public translate(tx: number, ty: number): Matrix; + translate(tx: number, ty: number): Matrix; /** * Applies scaling before the current transform of this matrix, as if using the add() method. Modifies this matrix object and also returns it so calls can be chained. @@ -97,7 +97,7 @@ declare class Matrix { * @param cx horizontal origin point from which to scale (if unspecified, scales from the local coordinates' origin point) * @param cy vertical origin point from which to scale */ - public scale(sx: number, sy?: number, cx?: number, cy?: number): Matrix; + scale(sx: number, sy?: number, cx?: number, cy?: number): Matrix; /** * Applies clockwise rotation before the current transform of this matrix, as if using the add() method. Modifies this matrix object and also returns it so calls can be chained. @@ -105,43 +105,43 @@ declare class Matrix { * @param cx horizontal origin point from which to rotate (if unspecified, scales from the local coordinates' origin point) * @param cy vertical origin point from which to rotate */ - public rotate(angle: number, cx?: number, cy?: number): Matrix; + rotate(angle: number, cx?: number, cy?: number): Matrix; /** * Returns x coordinate of the given point after transformation described by this matrix. See also Matrix.y and Matrix.transformPoint. * @param x * @param y */ - public x(x: number, y: number): number; + x(x: number, y: number): number; /** * Returns y coordinate of the given point after transformation described by this matrix. See also Matrix.x and Matrix.transformPoint. * @param x * @param y */ - public y(x: number, y: number): number; + y(x: number, y: number): number; /** * Returns x & y coordinates of the given point after transformation described by this matrix. * @param point */ - public transformPoint(point: Point): Point; + transformPoint(point: Point): Point; /** * Transforms a rectangle using this matrix, returning the axis-aligned bounds of the resulting rectangle. If this matrix has rotation, then the result will have different width & height from the original rectangle, due to axis alignment. See "Coordinate Spaces" for some illustrations of this. * @param rect */ - public transformRect(rect: Bounds): Bounds; + transformRect(rect: Bounds): Bounds; /** * @return The translation component of this matrix: [tx, ty]. Equals the `e` and `f` components of this matrix. */ - public getTranslate(): number[]; + getTranslate(): number[]; /** * Split the matrix into scale factors. This method assumes that there is no skew in the matrix. */ - public scaleFactors(): ScaleFactor; + scaleFactors(): ScaleFactor; /** * Returns a new matrix that contains only the translate and rotate components of the current matrix, with the given scale factors stripped out. Must be passed the exact scale factors returned by scaleFactors() for this matrix, and this matrix must have no skew/shear component. @@ -150,99 +150,99 @@ declare class Matrix { * @param scaleX horizontal scale component to remove * @param scaleY vertical scale component to remove */ - public removedScaleMatrix(scaleX: number, scaleY: number): Matrix; + removedScaleMatrix(scaleX: number, scaleY: number): Matrix; /** * @return true, if the matrix includes any skew (shear) */ - public hasSkew(): boolean; + hasSkew(): boolean; } declare class Color { /** * Integer 0-255. Get/set the alpha channel value. */ - public a: number; + a: number; /** * Integer 0-255. Get/set the red channel value. */ - public r: number; + r: number; /** * Integer 0-255. Get/set the green channel value. */ - public g: number; + g: number; /** * Integer 0-255. Get/set the blue channel value. */ - public b: number; + b: number; /** * Creates a new color instance. * @param value String in CSS color format (hex, rgb, rgba, hsl, hsla, hsv, hsva, or color name); or ARGB numeric value (unsigned 32-bit integer); or object with r, g, b, a keys all set to integers from 0 - 255 (if a is omitted, 255 is used). * @param opacity Optional, floating-point value from 0 - 1. Use when value parameter doesn't specify an opacity and you don't want the default 1.0 (100%) opacity. */ - public constructor(value: string | { r: number, g: number, b: number, a?: number }, opacity?: number); + constructor(value: string | { r: number, g: number, b: number, a?: number }, opacity?: number); /** * Convert to an object with r, g, b, a keys where r, g, b, a range from 0 - 255. */ - public toRgba(): { r: number, g: number, b: number, a: number }; + toRgba(): { r: number, g: number, b: number, a: number }; /** * Convert to hex string with "#" prefix. Ignores the Color's alpha value. Returns a 3-digit string if possible, otherwise returns a 6-digit string. * @param forceSixDigits True if you want the result to always have 6 digits. */ - public toHex(forceSixDigits: boolean): string; + toHex(forceSixDigits: boolean): string; /** * Returns a clone of the current color object */ - public clone(): Color; + clone(): Color; } declare class LinearGradientFill { /** * Array of objects representing each color and its position along the gradient line. The position (stop value) is a number 0.0 - 1.0. */ - public colorStops: {color:Color,stop:number}[]; + colorStops: {color:Color,stop:number}[]; /** * X position of the start of the gradient line, as a multiple of the object's bounding box: X=0 indicates the left edge of the bounding box and X=1 indicates the right edge. The gradient line may start or end outside the object's bounding box, so values may be < 0 or > 1. */ - public startX: number; + startX: number; /** * Y position of the start of the gradient line, as a multiple of the object's bounding box: Y=0 indicates the top edge of the bounding box and Y=1 indicates the bottom edge. The gradient line may start or end outside the object's bounding box, so values may be < 0 or > 1. */ - public startY: number; + startY: number; /** * X position of the end of the gradient line, as a multiple of the object's bounding box: X=0 indicates the left edge of the bounding box and X=1 indicates the right edge. The gradient line may start or end outside the object's bounding box, so values may be < 0 or > 1. */ - public endX: number; + endX: number; /** * Y position of the end of the gradient line, as a multiple of the object's bounding box: Y=0 indicates the top edge of the bounding box and Y=1 indicates the bottom edge. The gradient line may start or end outside the object's bounding box, so values may be < 0 or > 1. */ - public endY: number; + endY: number; /** * Create a new LinearGradientFill instance. */ - public constructor(); + constructor(); /** * Returns a copy of this instance. */ - public clone(): LinearGradientFill; + clone(): LinearGradientFill; /** * Returns an array of [startX, startY, endX, endY]. */ - public getEndPoints(): number[]; + getEndPoints(): number[]; /** * Shorthand for setting all four start/endpoint properties. @@ -251,7 +251,7 @@ declare class LinearGradientFill { * @param endX * @param endY */ - public setEndPoints(startX: number, startY: number, endX: number, endY: number); + setEndPoints(startX: number, startY: number, endX: number, endY: number); } /** @@ -265,11 +265,11 @@ declare class ImageFill { /** * The image is stretched (distorting its aspect ratio) so its edges line up exactly with the edges of the shape. (Similar to `object-fit: fill` in CSS). */ - public static SCALE_STRETCH: string; + static SCALE_STRETCH: string; /** * The image's aspect ratio is preserved and it it scaled to completely cover the area of the shape. This means on one axis the image's edges line up exactly with the edges of the shape, and on the other axis the image extends beyond the shape's bounds and is cropped. (Similar to `object-fit: cover` in CSS). */ - public static SCALE_COVER: string; + static SCALE_COVER: string; /** * How the image is scaled when the aspect ratio of the shape does not match the aspect ratio of the image: @@ -280,38 +280,38 @@ declare class ImageFill { * * To change this property, use cloneWithOverrides. */ - public scaleBehaviour: string; + scaleBehaviour: string; /** * Format the image data was originally encoded in, such as `image/gif` or `image/jpeg`. */ - public readonly mimeType: string; + readonly mimeType: string; /** * True if the image comes from a link to an external resource, such as Creative Cloud Libraries. */ - public readonly isLinkedContent: boolean; + readonly isLinkedContent: boolean; /** * Pixel dimensions of the underlying bitmap image data. */ - public readonly naturalWidth: number; + readonly naturalWidth: number; /** * Pixel dimensions of the underlying bitmap image data. */ - public readonly naturalHeight: number; + readonly naturalHeight: number; /** * * @param fileOrDataURI File object pointing to an image file; or a string containing a data: URI with a base-64 encoded image. */ - public constructor(fileOrDataURI: string | File); + constructor(fileOrDataURI: string | File); /** * @returns a new copy of this ImageFill. */ - public clone(): ImageFill; + clone(): ImageFill; } @@ -319,19 +319,19 @@ declare class Shadow { /** * X offset of the shadow relative to the shape it is attached to, in global coordinates (i.e. independent of the shape's rotation or any parent's rotation). May be negative. */ - public x: number; + x: number; /** * Y offset of the shadow relative to the shape it is attached to, in global coordinates (i.e. independent of the shape's rotation or any parent's rotation). May be negative. */ - public y: number; - public blur: number; - public color: Color; + y: number; + blur: number; + color: Color; /** * If false, the shadow is not rendered. The user can toggle this via a checkbox in the Properties panel. */ - public visible: boolean; + visible: boolean; /** * Creates a drop shadow style object with the given properties. @@ -341,7 +341,7 @@ declare class Shadow { * @param color * @param visible optional and defaults to true. */ - public constructor(x: number, y: number, blur: number, color: Color, visible: boolean) + constructor(x: number, y: number, blur: number, color: Color, visible: boolean) } declare class Blur { @@ -350,13 +350,13 @@ declare class Blur { * * (0 - 50) */ - public blurAmount: number; + blurAmount: number; /** * For background blur effects, the amount to increase or decrease the brightness of the background. Ignored for object blur effects. * * (-50 - 50) */ - public brightnessAmount: number; + brightnessAmount: number; /** * For background blur effects, the a multiplier on the opacity of the object's fill drawn over top of the blurred background. Useful to create a color tint on top of the blurred background. Does not affect stroke opacity. @@ -365,18 +365,18 @@ declare class Blur { * * (0.0 - 1.0) */ - public fillOpacity: number; + fillOpacity: number; /** * If true, renders a background blur effect: all objects beneath the shape are blurred (modulated by brightnessAmount), but the shape itself is still rendered with crisp edges (with its fill modulated by fillOpacity). * * If false, renders an object blur effect: the shape itself is blurred, and objects beneath it are unaffected. */ - public isBackgroundEffect: boolean; + isBackgroundEffect: boolean; /** * If false, the blur effect is not rendered. The user can toggle this via a checkbox in the Properties panel. */ - public visible: boolean; + visible: boolean; /** * Creates an object blur or background blur effect object with the given properties. @@ -403,109 +403,109 @@ declare abstract class SceneNode { /** * Returns a unique identifier for this node that stays the same when the file is closed & reopened, or if the node is moved to a different part of the document. Cut-Paste will result in a new guid, however. */ - public readonly guid: string; + readonly guid: string; /** * Returns the parent node. Null if this is the root node, or a freshly constructed node which has not been added to a parent yet. */ - public readonly parent: SceneNode | null; + readonly parent: SceneNode | null; /** * Returns a list of this node’s children. List is length 0 if the node has no children. The first child is lowest in the z order. * This list is not an Array, so you must use at(i) instead of [i] to access children by index. It has a number of Array-like methods such as forEach() for convenience, however. * The list is immutable. Use removeFromParent and addChild to add/remove child nodes. */ - public readonly children: SceneNodeList; + readonly children: SceneNodeList; /** * True if the node’s parent chain connects back to the document root node. */ - public readonly isInArtworkTree: boolean; + readonly isInArtworkTree: boolean; /** * True if this node is a type that could have children (e.g. an Artboard, Group, Boolean Group, etc.). */ - public readonly isContainer: boolean; + readonly isContainer: boolean; /** * True if this node is part of the current selection. To change which nodes are selected, use selection. */ - public readonly selected: boolean; + readonly selected: boolean; /** * False if this node has been hidden by the user (eyeball toggle in Layers panel). If true, the node may still be invisible for other reasons: a parent or grandparent has visible=false, the node has opacity=0%, the node is clipped by a mask, etc. */ - public visible: boolean; + visible: boolean; /** * (0.0-1.0)Node’s opacity setting. The overall visual opacity seen on canvas is determined by combining this value with the opacity of the node’s entire parent chain, as well as the opacity settings of its fill/stroke properties if this is a leaf node. */ - public opacity: number; + opacity: number; /** * Affine transform matrix that converts from the node’s local coordinate space to its parent’s coordinate space. The matrix never has skew or scale components, and if this node is an Artboard the matrix never has rotation either. Rather than working with the raw matrix directly, it may be easier to use methods such as placeInParentCoordinates or rotateAround. * Returns a fresh Matrix each time, so this can be mutated by the caller without interfering with anything. Mutating the returned Matrix does not change the node’s transform - only invoking the ‘transform’ setter changes the node. To modify an existing transform, always be sure to re-invoke the transform setter rather than just changing the Matrix object’s properties inline. See “Properties with object values”. * For an overview of node transforms & coordinate systems, see Coordinate spaces. */ - public readonly transform: Matrix; + readonly transform: Matrix; /** * The translate component of this node’s transform. Since translation is applied after any rotation in the transform Matrix, translation occurs along the parent’s X/Y axes, not the node’s own local X/Y axes. This is equivalent to the e & f fields in the transform Matrix. * For an overview of node positioning & coordinate systems, see Coordinate spaces. */ - public translation: Point; + translation: Point; /** * The rotation component of this node’s transform, in clockwise degrees. * For an overview of node transforms & coordinate systems, see Coordinate spaces. */ - public readonly rotation: number; + readonly rotation: number; /** * The node’s path bounds in document-global coordinate space (represented by a bounding box aligned with global X/Y axes). Path bounds match the selection outline seen in the XD, but exclude some visual parts of the node (outer stroke, drop shadow / blur, etc.). */ - public readonly globalBounds: Bounds; + readonly globalBounds: Bounds; /** * The node’s path bounds in its own local coordinate space. This coordinate space may be rotated and translated relative to the parent’s coordinate space. Path bounds match the selection outline seen in XD, but exclude some visual parts of the node (outerstroke, drop shadow / blur, etc.). * The visual top-left of a node’s path bounds is located at (localBounds.x, localBounds.y). This value is not necessarily (0,0) in the local coordinate space: for example, a text node’s baseline is at y=0 in local coordinates, so the top of the text has a negative y value. */ - public readonly localBounds: Bounds; + readonly localBounds: Bounds; /** * The node’s path bounds in its parent’s coordinate space (represented by a bounding box aligned with the parent’s X/Y axes - so if the node has rotation, the top-left of the node is not necessarily located at the top-left of boundsInParent). Path bounds match the selection outline seen in XD, but exclude some visual parts of the node (outer stroke, drop shadow / blur, etc.). */ - public readonly boundsInParent: Bounds; + readonly boundsInParent: Bounds; /** * The position of the node’s upper-left corner (localBounds.x, localBounds.y) in its parent’s coordinate space. If the node is rotated, this is not the same as the top-left corner of boundsInParent. This is a shortcut for node.transform.transformPoint({x: node.localBounds.x, y: node.localBounds.y}) */ - public readonly topLeftInParent: Point; + readonly topLeftInParent: Point; /** * The position of the node’s centerpoint in its own local coordinate space. Useful as an argument to rotateAround. This is a shortcut for {x: localBounds.x + localBounds.width/2, y: localBounds.y + localBounds.height/2}) */ - public readonly localCenterPoint: Point; + readonly localCenterPoint: Point; /** * The node’s draw bounds in document-global coordinate space. Draw bounds are larger than the selection outline seen in XD, including outer stroke, drop shadow / blur, etc. - every visible pixel of the node is encompassed by these bounds. This matches the image dimensions if the node is exported as a PNG/JPEG bitmap. */ - public readonly globalDrawBounds: Bounds; + readonly globalDrawBounds: Bounds; /** * Node name as seen in the Layers panel. Also used as filename during export. */ - public name: string; + name: string; /** * True if name is a generic, auto-generated string (e.g. “Rectangle 5”). False if name has been explicitly set. */ - public readonly hasDefaultName: boolean; + readonly hasDefaultName: boolean; /** * True if the node is locked, meaning it cannot normally be selected. */ - public locked: boolean; + locked: boolean; /** * True if the node should be included in the output of File > export > Batch and other bulk-export workflows. */ - public markedForExport: boolean; + markedForExport: boolean; /** * **Since**: XD 19 @@ -514,7 +514,7 @@ declare abstract class SceneNode { * * For other nodes, this property returns undefined and cannot be set. To determine whether those nodes scroll or remain fixed, walk up the parent chain and check this property on the topmost ancestor in the Artboard. */ - public fixedWhenScrolling?: boolean; + fixedWhenScrolling?: boolean; /** * Get all interactions that are triggered by this node in the document's interactive prototype. Each element in the array is an Interaction object which describes a gesture/event plus the action it produces. @@ -532,12 +532,12 @@ declare abstract class SceneNode { * * @see interactions.allInteractions */ - public readonly triggeredInteractions?: Array; + readonly triggeredInteractions?: Array; /** * True if the node's appearance comes from a link to an external resource, such as Creative Cloud Libraries or a separate XD document (in the case of a Linked Component instance). */ - public readonly hasLinkedContent: boolean; + readonly hasLinkedContent: boolean; /** * **Since:** XD 14 @@ -548,12 +548,12 @@ declare abstract class SceneNode { * * To store general metadata for the document overall, set pluginData on the root node of the scenegraph. Metadata on the root node can be changed from any edit context. */ - public pluginData: any; + pluginData: any; /** * Remove this node from its parent, effectively deleting it from the document. */ - public removeFromParent(): void; + removeFromParent(): void; /** * Move the node by the given number of pixels along the parent’s X/Y axes (if this node has no rotation, this is identical to moving the node along its own local X/Y axes). This is equivalent to modifying the value returned by ‘translation’ and then setting it back. @@ -561,7 +561,7 @@ declare abstract class SceneNode { * @param {number} deltaX * @param {number} deltaY */ - public moveInParentCoordinates(deltaX: number, deltaY: number): void; + moveInParentCoordinates(deltaX: number, deltaY: number): void; /** * Move the node so the given point in its local coordinates is placed at the given point in its parent’s coordinates (taking into account any rotation on this node, etc.). @@ -569,7 +569,7 @@ declare abstract class SceneNode { * @param {Point} registrationPoint Point in this node’s local coordinate space to align with parentPoint * @param {Point} parentPoint Point in this node’s parent’s coordinate space to move registrationPoint to */ - public placeInParentCoordinates( + placeInParentCoordinates( registrationPoint: Point, parentPoint: Point ): void; @@ -579,14 +579,14 @@ declare abstract class SceneNode { * @param {number} deltaAngle In degrees. * @param {Point} rotationCenter Point to rotate around, in node’s local coordinates. */ - public rotateAround(deltaAngle: number, rotationCenter: Point): void; + rotateAround(deltaAngle: number, rotationCenter: Point): void; /** * Attempts to change localBounds.width & height to match the specified sizes. This operation may not succeed, since some nodes are not resizable. Resizing one dimension may affect the other, if the node’s aspect ratio is locked. * @param {number} width * @param {number} height */ - public resize(width: number, height: number): void; + resize(width: number, height: number): void; } /** @@ -602,7 +602,7 @@ declare class GraphicNode extends SceneNode { * * Known issue: When modifying a gradient fill object specifically, you must clone the gradient returned by the getter before modifying it, to avoid issues with Undo history. */ - public fill: + fill: | null | Color | LinearGradientFill @@ -612,7 +612,7 @@ declare class GraphicNode extends SceneNode { /** * If false, the fill is not rendered. The user can toggle this via a checkbox in the Properties panel. */ - public fillEnabled: boolean; + fillEnabled: boolean; /** * The stroke color applied to this shape, if any. If this property is null or strokeEnabled is false, no stroke is drawn. Freshly created nodes have no stroke by default. Artboard objects ignore stroke settings. @@ -621,71 +621,71 @@ declare class GraphicNode extends SceneNode { * * To modify an existing stroke, always be sure to re-invoke the stroke setter rather than just changing the Color object’s properties inline. See “Properties with object values”. */ - public stroke: null | Color; + stroke: null | Color; /** * If false, the stroke is not rendered. The user can toggle this via a checkbox in the Properties panel. */ - public strokeEnabled: boolean; + strokeEnabled: boolean; /** * Thickness in pixels of the stroke. * value must be >= 0 */ - public strokeWidth: number; + strokeWidth: number; /** * @default `CENTER_STROKE` for most shapes, `INNER_STROKE` for Rectangle, Ellipse & Polygon * Position of the stroke relative to the shape’s path outline: GraphicNode.INNER_STROKE, OUTER_STROKE, or CENTER_STROKE. */ - public strokePosition: string; + strokePosition: string; /** * For Lines and non-closed Paths, how the dangling ends of the stroke are rendered: GraphicNode.STROKE_CAP_NONE, STROKE_CAP_SQUARE, or STROKE_CAP_ROUND. */ - public strokeEndCaps: string; + strokeEndCaps: string; /** * How sharp corners in the shape are rendered: GraphicNode.STROKE_JOIN_BEVEL, STROKE_JOIN_ROUND, or STROKE_JOIN_MITER. */ - public strokeJoins: string; + strokeJoins: string; /** * value must be >= 0 */ - public strokeMiterLimit: number; + strokeMiterLimit: number; /** * Empty array indicates a solid stroke. If non-empty, values represent the lengths of rendered and blank segments of the stroke’s dash pattern, repeated along the length of the stroke. The first value is the length of the first solid segment. If the array is odd length, the items are copied to double the array length. For example, [3] produces the same effect as [3, 3]. * * The appearance of each segment’s start/end follows the strokeEndCaps setting. */ - public strokeDashArray: Array; + strokeDashArray: Array; /** * Ignored unless strokeDashArray is non-empty. Shifts the “phase” of the repeating dash pattern along the length of the stroke. */ - public strokeDashOffset: number; + strokeDashOffset: number; /** * The node’s dropshadow, if any. If there is no shadow applied, this property may be null or shadow.visible may be false. */ - public shadow: null | Shadow; + shadow: null | Shadow; /** * The node’s object blur or background blur settings, if applicable. If there is no blur effect applied, this property may be null or blur.visible may be false. */ - public blur: null | Blur; + blur: null | Blur; /** * Returns a representation of the node’s outline in SVG syntax. Note that only nodes with strokePosition == GraphicNode.CENTER_STROKE can be faithfully rendered in actual SVG using the exact pathData shown here. */ - public readonly pathData: string; + readonly pathData: string; /** * True if the node’s image fill comes from a link to an external resource, such as Creative Cloud Libraries. */ - public readonly hasLinkedGraphicFill: boolean; + readonly hasLinkedGraphicFill: boolean; } /** @@ -699,19 +699,19 @@ declare class Artboard extends GraphicNode { /** * value must be >= 0 */ - public width: number; + width: number; /** * For scrollable Artboards, this is the total height encompassing all content - not just the viewport size (i.e. screen height). * * value must be >= 0 */ - public height: number; + height: number; /** * If Artboard is scrollable, this is the height of the viewport (e.g. mobile device screen size). Null if Artboard isn’t scrollable. */ - public viewportHeight: null | number; + viewportHeight: null | number; /** * **Since**: XD 19 @@ -727,7 +727,7 @@ declare class Artboard extends GraphicNode { * @see SceneNode.triggeredInteractions * @see interactions.allInteractions */ - public readonly incomingInteractions: Array<{triggerNode: SceneNode, interactions: Array}>; + readonly incomingInteractions: Array<{triggerNode: SceneNode, interactions: Array}>; /** * **Since**: XD 19 @@ -736,33 +736,33 @@ declare class Artboard extends GraphicNode { * * @see interactions.homeArtboard */ - public readonly isHomeArtboard: boolean; + readonly isHomeArtboard: boolean; /** * Adds a child node to this container node. You can only add leaf nodes this way; to create structured subtrees of content, use commands. * @param {SceneNode} node Child to add * @param {number} index Optional: index to insert child at. Child is appended to end of children list (top of z order) otherwise. */ - public addChild(node: SceneNode, index?: number): void; + addChild(node: SceneNode, index?: number): void; /** * Inserts a child node after the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately after this existing child */ - public addChildAfter(node: SceneNode, relativeTo: SceneNode): void; + addChildAfter(node: SceneNode, relativeTo: SceneNode): void; /** * Inserts a child node before the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately before this existing child */ - public addChildBefore(node: SceneNode, relativeTo: SceneNode): void; + addChildBefore(node: SceneNode, relativeTo: SceneNode): void; /** * Removes all children from this node. Equivalent to calling removeFromParent() on each child in turn, but faster. */ - public removeAllChildren(): void; + removeAllChildren(): void; } /** @@ -772,19 +772,19 @@ declare class Rectangle extends GraphicNode { /** * value must be >= 0 */ - public width: number; + width: number; /** * value must be >= 0 */ - public height: number; + height: number; /** * Default: `{topLeft:0, topRight:0, bottomRight:0, bottomLeft:0}` * The actual corner radius that is rendered is capped based on the size of the rectangle even if the radius value set here is higher (see {@link effectiveCornerRadii}) * To set all corners to the same value, use {@link setAllCornerRadii} */ - public cornerRadii: { + cornerRadii: { topLeft: number; topRight: number; bottomRight: number; @@ -794,12 +794,12 @@ declare class Rectangle extends GraphicNode { /** * True if any of the Rectangle’s four corners is rounded (corner radius > 0). */ - public readonly hasRoundedCorners: boolean; + readonly hasRoundedCorners: boolean; /** * The actual corner radius that is rendered may be capped by the size of the rectangle. Returns the actual radii that are currently in effect, which may be smaller than the {@link cornerRadii} values as a result. */ - public effectiveCornerRadii: { + effectiveCornerRadii: { topLeft: number; topRight: number; bottomRight: number; @@ -810,19 +810,19 @@ declare class Rectangle extends GraphicNode { * Set the rounding radius of all four corners of the Rectangle to the same value. The actual corner radius that is rendered is capped based on the size of the rectangle even if the radius value set here is higher (see {@link effectiveCornerRadii}) * To set the corners to different radius values, use {@link cornerRadii}. */ - public setAllCornerRadii(radius: number): void; + setAllCornerRadii(radius: number): void; } /** * Ellipse leaf node shape. */ declare class Ellipse extends GraphicNode { - public radiusX: number; - public radiusY: number; + radiusX: number; + radiusY: number; /** * True if the Ellipse is a circle (i.e., has a 1:1 aspect ratio). */ - public isCircle: boolean; + isCircle: boolean; } /** @@ -832,11 +832,11 @@ declare class Line extends GraphicNode { /** * Start point of the Line in local coordinate space.TEMP: To change the start point, use setStartEnd. */ - public readonly start: Point; + readonly start: Point; /** * Endpoint of the Line in local coordinate space.TEMP: To change the endpoint, use setStartEnd. */ - public readonly end: Point; + readonly end: Point; /** * Set the start and end points of the Line in local coordinate space. The values may be normalized by this setter, shifting the node’s translation and counter-shifting the start/end points. So the start/end setters may return values different from the values you passed this setter, even though the line’s visual bounds and appearance are the same. @@ -845,7 +845,7 @@ declare class Line extends GraphicNode { * @param {number} endX * @param {number} endY */ - public setSTartEnd( + setSTartEnd( startX: number, startY: number, endX: number, @@ -862,7 +862,7 @@ declare class Path extends GraphicNode { /** * Representation of the path outline in SVG syntax. Unlike other node types, pathData is writable here. Syntax is automatically normalized, so the getter may return a slightly different string than what you passed to the setter. */ - public pathData: string; + pathData: string; } /** @@ -888,12 +888,12 @@ declare class Polygon extends GraphicNode { /** * > 0 */ - public width: number; + width: number; /** * > 0 */ - public height: number; + height: number; /** * @default 3 @@ -907,23 +907,23 @@ declare class Polygon extends GraphicNode { * * To change corner count while guaranteeing the shape will not change size, save its original size first, set `cornerCount`, and then set size back to the saved values. */ - public cornerCount: number = 3; + cornerCount: number = 3; /** * True if any of the Polygon's corners is rounded (corner radius > 0). */ - public readonly hasRoundedCorners: boolean; + readonly hasRoundedCorners: boolean; /** * List of corner radius for each corner of the polygon. To set corner radius, use [setAllCornerRadii()](#Polygon-setAllCornerRadii). */ - public cornerRadii: number[]; + cornerRadii: number[]; /** * Set the corner radius of all corners of the Polygon to the same value. * @param {number} radius */ - public setAllCornerRadii(radius: number): void; + setAllCornerRadii(radius: number): void; } /** @@ -935,33 +935,33 @@ declare class BooleanGroup extends GraphicNode { /** * Which boolean operation is used to generate the path: BooleanGroup.PATH_OP_ADD, PATH_OP_SUBTRACT, PATH_OP_INTERSECT, or PATH_OP_EXCLUDE_OVERLAP. */ - public readonly pathOp: string; + readonly pathOp: string; /** * Adds a child node to this container node. You can only add leaf nodes this way; to create structured subtrees of content, use commands. * @param {SceneNode} node Child to add * @param {number} index Optional: index to insert child at. Child is appended to end of children list (top of z order) otherwise. */ - public addChild(node: SceneNode, index?: number): void; + addChild(node: SceneNode, index?: number): void; /** * Inserts a child node after the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately after this existing child */ - public addChildAfter(node: SceneNode, relativeTo: SceneNode): void; + addChildAfter(node: SceneNode, relativeTo: SceneNode): void; /** * Inserts a child node before the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately before this existing child */ - public addChildBefore(node: SceneNode, relativeTo: SceneNode): void; + addChildBefore(node: SceneNode, relativeTo: SceneNode): void; /** * Removes all children from this node. Equivalent to calling removeFromParent() on each child in turn, but faster. */ - public removeAllChildren(): void; + removeAllChildren(): void; } /** @@ -981,14 +981,14 @@ declare class Text extends GraphicNode { * * Setting text does not change styleRanges, so styles aligned with the old text’s string indices will continue to be applied to the new string’s indices unless you explicitly change styleRanges as well. */ - public text: string; + text: string; /** * Array of text ranges and their character style settings. Each range covers a set number of characters in the text content. Ranges are contiguous, with each one starting immediately after the previous one. Any characters past the end of the last range use the same style as the last range. * * When setting styleRanges, any fields missing from a given range default to the existing values from the last range in the old value of styleRanges. The styleRanges getter always returns fully realized range objects with all fields specified. */ - public styleRanges: Array<{ + styleRanges: Array<{ length: number; fontFamily: string; fontStyle: string; @@ -1004,32 +1004,32 @@ declare class Text extends GraphicNode { /** * If true, the text is drawn upside down. */ - public flipY: boolean; + flipY: boolean; /** * **Since:** XD 14 * Set the font family across all style ranges, or get the font family of the last style range (font family of all the text if one range covers all the text). Plugins should not assume any particular default value for fontFamily. */ - public fontFamily: string; + fontFamily: string; /** * **Since:** XD 14 * Set the font style across all style ranges, or get the font style of the last style range (font style of all the text if one range covers all the text). * @default non-italic normal weight style */ - public fontStyle: string; + fontStyle: string; /** * **Since:** XD 14 * Font size in document pixels. Set the font size across all style ranges, or get the font size of the last style range (font size of all the text if one range covers all the text). Plugins should not assume any particular default value for fontSize. */ - public fontSize: number; + fontSize: number; /** * Set the text color across all style ranges, or get the color of the last style range (color of all the text if one range covers all the text). Unlike most other nodes, text only allows a solid color fill - gradients and image fills are not supported. * @default null */ - public fill: Color | null; + fill: Color | null; /** * **Since:** XD 14 @@ -1038,14 +1038,14 @@ declare class Text extends GraphicNode { * Set the character spacing across all style ranges, or get the character spacing of the last style range (character spacing of all the text if one range covers all the text). * @default 0 */ - public charSpacing: number; + charSpacing: number; /** * **Since:** XD 14 * Set underline across all style ranges, or get the underline of the last style range (underline of all the text if one range covers all the text). * @default false */ - public underline: boolean; + underline: boolean; /** * @default false @@ -1053,7 +1053,7 @@ declare class Text extends GraphicNode { * * Set strikethrough across all style ranges, or get the strikethrough of the last style range (strikethrough of all the text if one range covers all the text). */ - public strikethrough: boolean = false; + strikethrough: boolean = false; /** * @default "none" @@ -1061,7 +1061,7 @@ declare class Text extends GraphicNode { * * Set textTransform ("none", "uppercase", "lowercase", or "titlecase") across all style ranges, or get the textTransform of the last style range. */ - public textTransform: 'none' | 'uppercase' | 'lowercase' | 'titlecase' = 'none'; + textTransform: 'none' | 'uppercase' | 'lowercase' | 'titlecase' = 'none'; /** * @default "none" @@ -1069,11 +1069,11 @@ declare class Text extends GraphicNode { * * Set textScript ("none" or "superscript" or "subscript") across all style ranges, or get the textScript of the last style range. */ - public textScript: 'none' | 'superscript' | 'subscript' = 'none'; + textScript: 'none' | 'superscript' | 'subscript' = 'none'; - public static readonly ALIGN_LEFT: string; - public static readonly ALIGN_CENTER: string; - public static readonly ALIGN_RIGHT: string; + static readonly ALIGN_LEFT: string; + static readonly ALIGN_CENTER: string; + static readonly ALIGN_RIGHT: string; /** * Horizontal alignment: Text.ALIGN_LEFT, ALIGN_CENTER, or ALIGN_RIGHT. This setting affects the layout of multiline text, and for point text it also affects how the text is positioned relative to its anchor point (x=0 in local coordinates) and what direction the text grows when edited by the user. @@ -1087,7 +1087,7 @@ declare class Text extends GraphicNode { * * @default Text.ALIGN_LEFT */ - public textAlign: string; + textAlign: string; /** * Distance between baselines in multiline text, in document pixels. The special value 0 causes XD to use the default line spacing defined by the font given the current font size & style. @@ -1096,7 +1096,7 @@ declare class Text extends GraphicNode { * * @default 0 */ - public lineSpacing: number; + lineSpacing: number; /** * **Since:** XD 14 @@ -1107,7 +1107,7 @@ declare class Text extends GraphicNode { * * @default 0 */ - public paragraphSpacing: number; + paragraphSpacing: number; /** * `Null` for point text. For area text, specifies the size of the rectangle within which text is wrapped and clipped. @@ -1116,12 +1116,12 @@ declare class Text extends GraphicNode { * * Changing area text to point text will also automatically insert hard line breaks ("\n") into the text to match the previous line wrapping's appearance exactly. */ - public areaBox: null | { width: number; height: number }; + areaBox: null | { width: number; height: number }; /** * Always false for point text. For area text, true if the text does not fit in the content box and its bottom is being clipped. */ - public readonly clippedByArea: boolean; + readonly clippedByArea: boolean; /** * **Since:** XD 19 @@ -1129,7 +1129,7 @@ declare class Text extends GraphicNode { * Set strikethrough across all style ranges, or get the strikethrough of the last style range (strikethrough of all the text if one range covers all the text). * @default false */ - public strikethrough: boolean; + strikethrough: boolean; /** * **Since:** XD 19 @@ -1138,7 +1138,7 @@ declare class Text extends GraphicNode { * * @default 'none' */ - public textTransform: 'none' | 'uppercase' | 'lowercase' | 'titlecase'; + textTransform: 'none' | 'uppercase' | 'lowercase' | 'titlecase'; } /** @@ -1154,33 +1154,33 @@ declare class Group extends SceneNode { /** * The mask shape applied to this group, if any. This object is also present in the group’s children list. Though it has no direct visual appearance of its own, the mask affects the entire groups’s appearance by clipping all its other content. */ - public readonly mask: SceneNode | null; + readonly mask: SceneNode | null; /** * Adds a child node to this container node. You can only add leaf nodes this way; to create structured subtrees of content, use commands. * @param {SceneNode} node Child to add * @param {number} index Optional: index to insert child at. Child is appended to end of children list (top of z order) otherwise. */ - public addChild(node: SceneNode, index?: number): void; + addChild(node: SceneNode, index?: number): void; /** * Inserts a child node after the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately after this existing child */ - public addChildAfter(node: SceneNode, relativeTo: SceneNode): void; + addChildAfter(node: SceneNode, relativeTo: SceneNode): void; /** * Inserts a child node before the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately before this existing child */ - public addChildBefore(node: SceneNode, relativeTo: SceneNode): void; + addChildBefore(node: SceneNode, relativeTo: SceneNode): void; /** * Removes all children from this node. Equivalent to calling removeFromParent() on each child in turn, but faster. */ - public removeAllChildren(): void; + removeAllChildren(): void; } /** @@ -1198,39 +1198,39 @@ declare class SymbolInstance extends SceneNode { /** * An identifier unique within this document that is shared by all instances of the same component. */ - public readonly symbolId: string; + readonly symbolId: string; /** * True if this is the "master" instance of the component, which forms the template for all new instances. When the user edits the master, those changes are synced to all other instances of the component (unless blocked by "overrides" * @see SymbolInstance */ - public readonly isMaster: boolean; + readonly isMaster: boolean; /** * Adds a child node to this container node. You can only add leaf nodes this way; to create structured subtrees of content, use commands. * @param {SceneNode} node Child to add * @param {number} index Optional: index to insert child at. Child is appended to end of children list (top of z order) otherwise. */ - public addChild(node: SceneNode, index?: number): void; + addChild(node: SceneNode, index?: number): void; /** * Inserts a child node after the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately after this existing child */ - public addChildAfter(node: SceneNode, relativeTo: SceneNode): void; + addChildAfter(node: SceneNode, relativeTo: SceneNode): void; /** * Inserts a child node before the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately before this existing child */ - public addChildBefore(node: SceneNode, relativeTo: SceneNode): void; + addChildBefore(node: SceneNode, relativeTo: SceneNode): void; /** * Removes all children from this node. Equivalent to calling removeFromParent() on each child in turn, but faster. */ - public removeAllChildren(): void; + removeAllChildren(): void; } /** @@ -1242,37 +1242,37 @@ declare class RepeatGrid extends SceneNode { /** * Defines size of the RepeatGrid. Cells are created and destroyed as necessary to fill the current size. Cells that only partially fit will be clipped. */ - public width: number; + width: number; /** * Defines size of the RepeatGrid. Cells are created and destroyed as necessary to fill the current size. Cells that only partially fit will be clipped. */ - public height: number; + height: number; /** * Number of grid columns */ - public numColumns: number; + numColumns: number; /** * Number of grid rows */ - public numRows: number; + numRows: number; /** * Horizontal spacing between grid cells/columns */ - public paddingX: number; + paddingX: number; /** * Vertical spacing between grid cells/rows */ - public paddingY: number; + paddingY: number; /** * The size of each grid cell. The size of each cell’s content can vary slightly due to text overrides; the cell size is always set to the width of the widest cell content and the height of the tallest cell content. */ - public cellSize: { width: number; height: number }; + cellSize: { width: number; height: number }; /** * Attach a sequence of text values to the instances of a given text node across all the cells of a Repeat Grid. The sequence is repeated as necessary to cover all the grid cells. This is a persistent data binding, so if the Repeat Grid is resized later to increase the number of grid cells, items from this sequence will be used to fill the text values of the new cells. @@ -1282,7 +1282,7 @@ declare class RepeatGrid extends SceneNode { * @param {Text} textNode A Text node exemplar that is an immediate child of one of this RepeatGrid's cells. The data series will be bound to this text node and all corresponding copies of it in the other grid cells. * @param {string[]} textValues Array of one or more strings. Empty strings are ignored. */ - public attachTextDataSeries(textNode: Text, textValues: string[]): void; + attachTextDataSeries(textNode: Text, textValues: string[]): void; /** * Attach a sequence of image fills to the instances of a given shape node across all the cells of a Repeat Grid. The sequence is repeated as necessary to cover all the grid cells. This is a persistent data binding, so if the Repeat Grid is resized later to increase the number of grid cells, items from this sequence will be used to set the image fill in the new cells. @@ -1299,26 +1299,26 @@ declare class RepeatGrid extends SceneNode { * @param {SceneNode} node Child to add * @param {number} index Optional: index to insert child at. Child is appended to end of children list (top of z order) otherwise. */ - public addChild(node: SceneNode, index?: number): void; + addChild(node: SceneNode, index?: number): void; /** * Inserts a child node after the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately after this existing child */ - public addChildAfter(node: SceneNode, relativeTo: SceneNode): void; + addChildAfter(node: SceneNode, relativeTo: SceneNode): void; /** * Inserts a child node before the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately before this existing child */ - public addChildBefore(node: SceneNode, relativeTo: SceneNode): void; + addChildBefore(node: SceneNode, relativeTo: SceneNode): void; /** * Removes all children from this node. Equivalent to calling removeFromParent() on each child in turn, but faster. */ - public removeAllChildren(): void; + removeAllChildren(): void; } /** @@ -1336,26 +1336,26 @@ declare class RootNode extends SceneNode { * @param {SceneNode} node Child to add * @param {number} index Optional: index to insert child at. Child is appended to end of children list (top of z order) otherwise. */ - public addChild(node: SceneNode, index?: number): void; + addChild(node: SceneNode, index?: number): void; /** * Inserts a child node after the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately after this existing child */ - public addChildAfter(node: SceneNode, relativeTo: SceneNode): void; + addChildAfter(node: SceneNode, relativeTo: SceneNode): void; /** * Inserts a child node before the given reference node. * @param {SceneNode} node Child to add * @param {SceneNode} relativeTo New child is added immediately before this existing child */ - public addChildBefore(node: SceneNode, relativeTo: SceneNode): void; + addChildBefore(node: SceneNode, relativeTo: SceneNode): void; /** * Removes all children from this node. Equivalent to calling removeFromParent() on each child in turn, but faster. */ - public removeAllChildren(): void; + removeAllChildren(): void; } /** diff --git a/types/uxp.d.ts b/types/uxp.d.ts index db107f7..3f9d8c7 100644 --- a/types/uxp.d.ts +++ b/types/uxp.d.ts @@ -4,41 +4,41 @@ declare module storage { /** * An Entry is the base class for `File` and `Folder`. You'll typically never instantiate an `Entry` directly, but it provides the common fields and methods that both `File` and `Folder` share. */ - static class Entry { + interface Entry { /** * Indicates that this instance is an `Entry`. Useful for type-checking. */ - public isEntry: boolean; + isEntry: true; /** * Indicates that this instance is not a `File`. Useful for type-checking. */ - public readonly isFile: boolean; + readonly isFile: boolean; /** * Indicates that this instance is **not** a folder. Useful for type-checking. */ - public readonly isFolder: boolean; + readonly isFolder: boolean; /** * The name of this entry. Read-only. */ - public readonly name: string; + readonly name: string; /** * The associated provider that services this entry. Read-only. */ - public readonly provider: FileSystemProvider; + readonly provider: FileSystemProvider; /** * The url of this entry. You can use this url as input to other entities of the extension system like for eg: set as src attribute of a Image widget in UI. Read-only. */ - public readonly url: string; + readonly url: string; /** * The platform native file-system path of this entry. Read-only */ - public readonly nativePath: string; + readonly nativePath: string; /** * Copies this entry to the specified `folder`. @@ -50,7 +50,7 @@ declare module storage { * @throws errors.PermissionDeniedError if the underlying file system rejects the attempt * @throws errors.OutOfSpaceError if the file system is out of storage space */ - public copyTo(folder: Folder, options?): Promise; + copyTo(folder: Folder, options?): Promise; /** * Moves this entry to the target folder, optionally specifying a new name. @@ -59,18 +59,22 @@ declare module storage { * @param {boolean=false} options.overwrite If true allows the move to overwrite existing files * @param {string=} options.newName If specified, the entry is renamed to this name */ - public moveTo(folder: Folder, options?): Promise; + moveTo(folder: Folder, options?): Promise; /** * Removes this entry from the file system. If the entry is a folder, all the contents will also be removed. */ - public delete(): Promise; + delete(): Promise; /** * @returns this entry's metadata. */ - public getMetadata(): Promise; + getMetadata(): Promise; + /** + * Returns the details of the given entry like name, type and native path in a readable string format. + */ + toString(): string; } /** @@ -84,43 +88,52 @@ declare module storage { * You'll not instantiate this directly; use Entry#getMetadata to do so. * @see {@link Entry.getMetadata} */ - static class EntryMetadata { + interface EntryMetadata { /** * The name of the entry. */ - public readonly name: string; + readonly name: string; /** * The size of the entry, if a file. Zero if a folder. */ - public readonly size: number; + readonly size: number; /** * The date this entry was created. */ - public readonly dateCreated: Date; + readonly dateCreated: Date; /** * The date this entry was modified. */ - public readonly dateModified: Date; + readonly dateModified: Date; /** * Indicates if the entry is a file */ - public readonly isFile: boolean; + readonly isFile: boolean; /** * Indicates if the entry is a folder */ - public readonly isFolder: boolean; + readonly isFolder: boolean; } /** * Represents a file on a file system. Provides methods for reading from and writing to the file. You'll never instantiate a File directly; instead you'll get access via a FileSystemProvider. * @see {@link FileSystemProvider} */ - static class File extends Entry { + interface File extends Entry { + /** + * Indicates if the entry is a file + */ + readonly isFile: true; + /** + * Indicates if the entry is a folder + */ + readonly isFolder: false; + /** * Indicates whether this file is read-only or read-write. See readOnly and readWrite. * @see {@link modes} */ - public mode: Symbol; + mode: typeof modes.readOnly | typeof modes.readWrite; /** * Reads data from the file and returns it. The file format can be specified with the `format` option. If a format is not supplied, the file is assumed to be a text file using UTF8 encoding. @@ -128,7 +141,7 @@ declare module storage { * @param {Symbol=} options.format The format of the file; see utf8 and blob. * @see {@link formats} */ - public read(options?): Promise; + read(options?): Promise; /** * Writes data to a file, appending if desired. The format of the file is controlled via the `format` option, and defaults to UTF8. @@ -142,28 +155,13 @@ declare module storage { * @param {boolean=false} options.append if `true`, the data is written to the end of the file * @see {@link formats} */ - public write(data: string | ArrayBuffer, options?): Promise; - - /** - * Determines if the entry is a file or not. This is safe to use even if the entry is `null` or `undefined`. - * @param entry the entry to check - */ - public static isFile(entry: any): boolean; + write(data: string | ArrayBuffer, options?): Promise; } /** * Provides access to files and folders on a file system. You'll typically not instantiate this directly; instead you'll use an instance of one that has already been created for you. This class is abstract, meaning that you'll need to provide your own implementation in order to use it effectively. */ - static class FileSystemProvider { - /** - * Indicates that this is a {@link FileSystemProvider}. Useful for type-checking. - */ - public readonly isFileSystemProvider: boolean; - /** - * An array of the domains this file system supports. If the file system can open a file picker to the user's `documents` folder, for example, then `userDocuments` will be in this list. - */ - public readonly supportedDomains: Symbol[]; - + interface FileSystemProvider { /** * Gets a file (or files) from the file system provider for the purpose of opening them. Files are read-only. * @@ -174,7 +172,7 @@ declare module storage { * * @returns the selected files, or empty if no file were selected. */ - public getFileForOpening(options?): Promise; + getFileForOpening(options?): Promise; /** * Gets a file reference suitable for saving. The file is read-write. Any file picker displayed will be of the "save" variety. @@ -187,7 +185,7 @@ declare module storage { * @param {string[]} options.types Required. Allowed file extensions, with no "." prefix. * @returns the selected file, or `null` if no file were selected. */ - public getFileForSaving(options?): Promise; + getFileForSaving(options?): Promise; /** * Gets a folder from the file system via a folder picker dialog. The files and folders within can be accessed via {@link Folder.getEntries}. Any files within are read-write. @@ -196,41 +194,34 @@ declare module storage { * * @returns the selected folder, or `null` if no folder is selected. */ - public getFolder(): Promise; + getFolder(): Promise; /** * Returns a temporary folder. The contents of the folder will be removed when the extension is disposed. */ - public getTemporaryFolder(): Promise; + getTemporaryFolder(): Promise; /** * Returns a folder that can be used for extension's data storage without user interaction. It is persistent across host-app version upgrades. */ - public getDataFolder(): Promise; + getDataFolder(): Promise; /** * Returns an plugin's folder – this folder and everything within it are read only. This contains all the Plugin related packaged assets. */ - public getPluginFolder(): Promise; + getPluginFolder(): Promise; /** * Returns the fs url of given entry. * @param entry the entry */ - public getFsUrl(entry: Entry): string; + getFsUrl(entry: Entry): string; /** * Returns the platform native file system path of given entry. * @param entry the entry */ - public getNativePath(entry: Entry): string; - - /** - * Checks if the supplied object is a {@link FileSystemProvider}. It's safe to use even if the object is `null` or `undefined`. Useful for type checking. - * @param fs the object to check - * @returns If `true`, the object is a file system provider - */ - public static isFileSystemProvider(fs: any): boolean; + getNativePath(entry: Entry): string; } static class LocalFileSystemProvider extends FileSystemProvider { @@ -242,21 +233,19 @@ declare module storage { */ static class Folder extends Entry { /** - * Returns an array of entries contained within this folder. - * @returns The entries within the folder. + * Indicates if the entry is a file */ - public getEntries(): Promise; + readonly isFile: false; + /** + * Indicates if the entry is a folder + */ + readonly isFolder: true; /** - * Creates an entry within this folder and returns the appropriate instance. - * @param {string} name the name of the entry to create - * @param {object} options - * @param {Symbol=types.file} options.type Indicates which kind of entry to create. Pass {@link types.folder} to create a new folder. - * @param {boolean=false} options.overwrite If `true`, the create attempt can overwrite an existing file - * - * @returns the created entry + * Returns an array of entries contained within this folder. + * @returns The entries within the folder. */ - public createEntry(name: string, options?): Promise; + getEntries(): Promise; /** * Creates a File Entry object within this folder and returns the appropriate instance. Note that this method just create a file entry object and not the actual file on the disk. The file actually gets created when you call for eg: write method on the file entry object. @@ -266,14 +255,14 @@ declare module storage { * * @returns the created entry */ - public createFile(name: string, options?): Promise; + createFile(name: string, options?): Promise; /** * Creates a Folder within this folder and returns the appropriate instance. * @param {string} name the name of the folder to create * @returns the created entry */ - public createFolder(name: string): Promise; + createFolder(name: string): Promise; /** * Gets an entry from within this folder and returns the appropriate instance. @@ -281,7 +270,7 @@ declare module storage { * * @returns the fetched entry. */ - public getEntry(filePath: string): Promise; + getEntry(filePath: string): Promise; /** * Renames an entry to a new name. @@ -290,15 +279,7 @@ declare module storage { * @param {object} options * @param {boolean=false} options.overwrite if `true`, renaming can overwrite an existing entry */ - public renameEntry(entry: Entry, newName: string, options?): Promise; - - /** - * Checks if an entry is a folder. Safe to use if entry might be `null` or `undefined`. Useful for type checking. - * @param entry the entry to check - * - * @returns if `true`, the entry is a folder - */ - public static isFolder(entry: any): boolean; + renameEntry(entry: Entry, newName: string, options?): Promise; } export const localFileSystem: LocalFileSystemProvider; @@ -403,11 +384,11 @@ declare module storage { /** * UTF8 File encoding */ - const utf8: Symbol; + const utf8: unique symbol; /** * Binary file encoding */ - const binary: Symbol; + const binary: unique symbol; } /** @@ -417,11 +398,11 @@ declare module storage { /** * The file is read-only; attempts to write will fail. */ - const readOnly: Symbol; + const readOnly: unique symbol; /** * The file is read-write. */ - const readWrite: Symbol; + const readWrite: unique symbol; } /** @@ -431,12 +412,12 @@ declare module storage { /** * A file; used when creating an entity */ - const file: Symbol; + const file: unique symbol; /** * A folder; used when creating an entity */ - const folder: Symbol; + const folder: unique symbol; } } -export {shell, storage}; +export = {shell, storage}; diff --git a/types/viewport.d.ts b/types/viewport.d.ts index 2afb941..aa564b1 100644 --- a/types/viewport.d.ts +++ b/types/viewport.d.ts @@ -8,12 +8,12 @@ declare class viewport { /** * The current viewport bounds expressed in global coordinates. */ - public static readonly bounds: {x:number,y:number,width:number,height:number}; + static readonly bounds: {x:number,y:number,width:number,height:number}; /** * The current viewport zoom factor (where 1.0 = 100% zoom, 0.5 = 50% zoom, etc.). */ - public static readonly zoomFactor: number; + static readonly zoomFactor: number; /** * Smoothly pan the viewport to bring the entire given region into view. If the region is already fully in view, does nothing. If the given region is too large to fit entirely in view, it is simply centered (zoom remains unchanged). @@ -21,7 +21,7 @@ declare class viewport { * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. * @param {!SceneNode} node The node that gets scrolled into view */ - public static scrollIntoView(node: SceneNode): void; + static scrollIntoView(node: SceneNode): void; /** * Smoothly pan the viewport to bring the entire given region into view. If the region is already fully in view, does nothing. If the given region is too large to fit entirely in view, it is simply centered (zoom remains unchanged). @@ -32,14 +32,14 @@ declare class viewport { * @param width * @param height */ - public static scrollIntoView(x: number, y:number, width:number, height:number): void; + static scrollIntoView(x: number, y:number, width:number, height:number): void; /** * Smoothly pan the viewport to center on a specific point in the document's global coordinates. Even if the point is already in view, the view pans until it is centered. * @param {number} x The x-coordinate of the centered point (in the document's global coordinates) * @param {number} y The y-coordinate of the centered point (in the document's global coordinates) */ - public static scrollToCenter(x: number, y:number): void; + static scrollToCenter(x: number, y:number): void; /** * Zoom & pan the view as needed so the given region fills the viewport (with some padding). If the region is large, zooms out as needed so it fits entirely in view. If the region is smaller, zooms in so the region fills the entire viewport - may zoom in past 100% to achieve this. @@ -47,7 +47,7 @@ declare class viewport { * The region can be defined by passing a {@link SceneNode}, or by explicitly specifying a rectangle in global coordinates. * @param {!SceneNode} node */ - public static zoomToRect(node: SceneNode): void; + static zoomToRect(node: SceneNode): void; /** * Zoom & pan the view as needed so the given region fills the viewport (with some padding). If the region is large, zooms out as needed so it fits entirely in view. If the region is smaller, zooms in so the region fills the entire viewport - may zoom in past 100% to achieve this. @@ -58,7 +58,7 @@ declare class viewport { * @param {number} width * @param {number} height */ - public static zoomToRect(x: number, y:number, width:number, height:number): void; + static zoomToRect(x: number, y:number, width:number, height:number): void; } export = viewport;