Skip to content

Commit

Permalink
- Adjusted sample.js file for "new" File/Folder structure – Fixed #42
Browse files Browse the repository at this point in the history
- Fixed symbol declarations in `uxp` module – Fixed #48
- Removed redundant public keyword (if it weren't public, we wouldn't need it in the typings, after all) – Fixed #50
  • Loading branch information
pklaschka committed Jun 24, 2019
1 parent df6cf30 commit 1160e75
Show file tree
Hide file tree
Showing 10 changed files with 306 additions and 319 deletions.
12 changes: 9 additions & 3 deletions sample.js
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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 = {
Expand Down
8 changes: 4 additions & 4 deletions types/application.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ declare class application {
* @param renditions List of renditions to generate
* @return Promise<Array<RenditionResult>, 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<RenditionResult[] | string>;
static createRenditions(renditions: RenditionSettings[]): Promise<RenditionResult[] | string>;

/**
* 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;
12 changes: 6 additions & 6 deletions types/assets.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ declare module assets {
* allColors = assets.colors.get();
*
*/
public static get(): Array<ColorAsset | GradientAsset>;
static get(): Array<ColorAsset | GradientAsset>;

/**
* Add color/gradient assets to the collection.
Expand All @@ -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<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;
static add(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;

/**
* Delete color/gradient assets from the collection.
Expand All @@ -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<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;
static delete(colorAssets: Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset | Array<Color | ColorAsset | LinearGradientFill | RadialGradientFill | GradientAsset>): number;
}

/**
Expand All @@ -163,7 +163,7 @@ declare module assets {
* allCharacterStyles = assets.characterStyles.get();
*
*/
public static get(): Array<CharacterStyleAsset>;
static get(): Array<CharacterStyleAsset>;

/**
* Add one or more character style assets to the collection.
Expand All @@ -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<CharacterStyleAsset>): number;
static add(charStyleAssets: CharacterStyleAsset | Array<CharacterStyleAsset>): number;

/**
* Delete one or more character style assets from the collection.
Expand All @@ -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<CharacterStyleAsset>): number;
static delete(charStyleAssets: CharacterStyleAsset | Array<CharacterStyleAsset>): number;
}
}

Expand Down
2 changes: 1 addition & 1 deletion types/clipboard.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
40 changes: 20 additions & 20 deletions types/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
18 changes: 9 additions & 9 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<SceneNode>;

public map(
map(
callback: (sceneNode: SceneNode, index: number) => any,
thisArg?: object
): Array<any>;

public some(
some(
callback: (sceneNode: SceneNode, index: number) => boolean,
thisArg?: object
): boolean;

public at(index: number): SceneNode | null;
at(index: number): SceneNode | null;
}

/**
Expand Down Expand Up @@ -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);
}
}
4 changes: 2 additions & 2 deletions types/interactions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand All @@ -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<Interaction> }>;
static readonly allInteractions: Array<{ triggerNode: SceneNode, interactions: Array<Interaction> }>;
}

/**
Expand Down
Loading

0 comments on commit 1160e75

Please sign in to comment.