diff --git a/.eslintrc.yml b/.eslintrc.yml
index b19c5391f..07ad2736a 100644
--- a/.eslintrc.yml
+++ b/.eslintrc.yml
@@ -110,6 +110,9 @@ globals:
MSImmutableStarShape: false
MSImmutableTriangleShape: false
MSImmutableRectangleShape: false
+ MSSliceLayer: false
+ MSImmutableSliceLayer: false
+ MSExportFormat: false
rules:
###########
diff --git a/CHANGELOG.json b/CHANGELOG.json
index c7a3e1ce6..655d9c826 100644
--- a/CHANGELOG.json
+++ b/CHANGELOG.json
@@ -1,6 +1,8 @@
{
"unreleased": [
- "[New] Add `verticalAlignment` property to Text",
+ "[New] Add support for Slices",
+ "[New] Add `exportFormats` property on Layer",
+ "[Improved] No need to specify the type when there is no choice (like Document.pages can only contain Pages, Layer.exportFormats can only contain ExportFormats, etc.)",
"[New] Add UI.getInputFromUser method and deprecate the other input methods",
"[New] Add some `getParent*` methods on Layer"
],
diff --git a/Source/dom/WrappedObject.js b/Source/dom/WrappedObject.js
index 377a3996c..fecf598ee 100644
--- a/Source/dom/WrappedObject.js
+++ b/Source/dom/WrappedObject.js
@@ -63,6 +63,9 @@ export class WrappedObject {
* @param {Object} object - The Sketch model object to wrap.
*/
static fromNative(sketchObject) {
+ if (!sketchObject) {
+ return sketchObject
+ }
return new this({
sketchObject,
})
diff --git a/Source/dom/enums.js b/Source/dom/enums.js
index d1a1799ba..e36d064c4 100644
--- a/Source/dom/enums.js
+++ b/Source/dom/enums.js
@@ -25,4 +25,6 @@ export const Types = {
SharedStyle: 'SharedStyle',
DataOverride: 'DataOverride',
ShapePath: 'ShapePath',
+ Slice: 'Slice',
+ ExportFormat: 'ExportFormat',
}
diff --git a/Source/dom/index.js b/Source/dom/index.js
index ee875010c..44cf60342 100755
--- a/Source/dom/index.js
+++ b/Source/dom/index.js
@@ -20,6 +20,7 @@ export { Page } from './layers/Page'
export { SymbolMaster } from './layers/SymbolMaster'
export { SymbolInstance } from './layers/SymbolInstance'
export { HotSpot } from './layers/HotSpot'
+export { Slice } from './layers/Slice'
export { Types } from './enums'
export { wrapObject as fromNative } from './wrapNativeObject'
diff --git a/Source/dom/layers/Group.js b/Source/dom/layers/Group.js
index 9adeb31f2..7cb0c2809 100644
--- a/Source/dom/layers/Group.js
+++ b/Source/dom/layers/Group.js
@@ -1,9 +1,9 @@
+import { toArray } from 'util'
import { DefinedPropertiesKey } from '../WrappedObject'
import { StyledLayer } from './StyledLayer'
import { Rectangle } from '../models/Rectangle'
import { Types } from '../enums'
import { Factory } from '../Factory'
-import { toArray } from '../utils'
import { wrapNativeObject, wrapObject } from '../wrapNativeObject'
/**
@@ -45,7 +45,7 @@ export class Group extends StyledLayer {
if (this.isImmutable()) {
return this
}
- this._object.resizeToFitChildrenWithOption_(0)
+ this._object.fixGeometryWithOptions(0)
return this
}
}
diff --git a/Source/dom/layers/HotSpot.js b/Source/dom/layers/HotSpot.js
index 337571095..5cc7d240a 100644
--- a/Source/dom/layers/HotSpot.js
+++ b/Source/dom/layers/HotSpot.js
@@ -45,3 +45,5 @@ HotSpot.type = Types.HotSpot
HotSpot[DefinedPropertiesKey] = { ...Layer[DefinedPropertiesKey] }
Factory.registerClass(HotSpot, MSHotspotLayer)
Factory.registerClass(HotSpot, MSImmutableHotspotLayer)
+
+delete HotSpot[DefinedPropertiesKey].exportFormats
diff --git a/Source/dom/layers/Image.js b/Source/dom/layers/Image.js
index e9faeb8c1..1e15ed1b2 100644
--- a/Source/dom/layers/Image.js
+++ b/Source/dom/layers/Image.js
@@ -4,7 +4,6 @@ import { ImageData } from '../models/ImageData'
import { Rectangle } from '../models/Rectangle'
import { Types } from '../enums'
import { Factory } from '../Factory'
-import { wrapObject } from '../wrapNativeObject'
/**
* Represents an image layer.
@@ -36,7 +35,7 @@ Factory.registerClass(Image, MSImmutableBitmapLayer)
Image.define('image', {
get() {
- return wrapObject(this._object.image())
+ return ImageData.fromNative(this._object.image())
},
set(image) {
if (this.isImmutable()) {
diff --git a/Source/dom/layers/Layer.js b/Source/dom/layers/Layer.js
index b0c6de8e4..98de73ccd 100644
--- a/Source/dom/layers/Layer.js
+++ b/Source/dom/layers/Layer.js
@@ -1,8 +1,11 @@
+import { toArray } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
import { Factory } from '../Factory'
import { Rectangle } from '../models/Rectangle'
import { wrapObject, wrapNativeObject } from '../wrapNativeObject'
import { Flow } from '../models/Flow'
+import { ExportFormat } from '../models/ExportFormat'
+import { Types } from '../enums'
/**
* Abstract class that represents a Sketch layer.
@@ -283,3 +286,24 @@ Layer.define('locked', {
this._object.setIsLocked(locked)
},
})
+
+Layer.define('exportFormats', {
+ get() {
+ return toArray(this._object.exportOptions().exportFormats() || []).map(
+ ExportFormat.fromNative.bind(ExportFormat)
+ )
+ },
+ set(exportFormats) {
+ if (this.isImmutable()) {
+ return
+ }
+
+ this._object
+ .exportOptions()
+ .setExportFormats(
+ toArray(exportFormats).map(
+ e => wrapObject(e, Types.ExportFormat).sketchObject
+ )
+ )
+ },
+})
diff --git a/Source/dom/layers/Page.js b/Source/dom/layers/Page.js
index be060de62..fd431b129 100644
--- a/Source/dom/layers/Page.js
+++ b/Source/dom/layers/Page.js
@@ -85,6 +85,7 @@ delete Page[DefinedPropertiesKey].flow
delete Page[DefinedPropertiesKey].style
delete Page[DefinedPropertiesKey].locked
delete Page[DefinedPropertiesKey].hidden
+delete Page[DefinedPropertiesKey].exportFormats
// override setting up the parent as it's needs to a be a Document
Page.define('parent', {
diff --git a/Source/dom/layers/Slice.js b/Source/dom/layers/Slice.js
new file mode 100644
index 000000000..0674bfaf8
--- /dev/null
+++ b/Source/dom/layers/Slice.js
@@ -0,0 +1,28 @@
+import { DefinedPropertiesKey } from '../WrappedObject'
+import { Layer } from './Layer'
+import { Rectangle } from '../models/Rectangle'
+import { Types } from '../enums'
+import { Factory } from '../Factory'
+
+/**
+ * Represents a slice.
+ */
+export class Slice extends Layer {
+ constructor(group = {}) {
+ if (!group.sketchObject) {
+ // eslint-disable-next-line no-param-reassign
+ group.sketchObject = Factory.createNative(Slice)
+ .alloc()
+ .initWithFrame(new Rectangle(0, 0, 100, 100).asCGRect())
+ }
+
+ super(group)
+ }
+}
+
+Slice.type = Types.Slice
+Slice[DefinedPropertiesKey] = { ...Layer[DefinedPropertiesKey] }
+Factory.registerClass(Slice, MSSliceLayer)
+Factory.registerClass(Slice, MSImmutableSliceLayer)
+
+delete Slice[DefinedPropertiesKey].flow
diff --git a/Source/dom/layers/StyledLayer.js b/Source/dom/layers/StyledLayer.js
index 371d252a9..678877d79 100644
--- a/Source/dom/layers/StyledLayer.js
+++ b/Source/dom/layers/StyledLayer.js
@@ -1,8 +1,8 @@
+import { isNativeObject } from 'util'
import { DefinedPropertiesKey } from '../WrappedObject'
import { Factory } from '../Factory'
import { Layer } from './Layer'
import { Style } from '../style/Style'
-import { isNativeObject } from '../utils'
import { SharedStyle } from '../models/SharedStyle'
import { wrapObject } from '../wrapNativeObject'
diff --git a/Source/dom/layers/SymbolInstance.js b/Source/dom/layers/SymbolInstance.js
index 9d0a82729..02088a465 100644
--- a/Source/dom/layers/SymbolInstance.js
+++ b/Source/dom/layers/SymbolInstance.js
@@ -1,10 +1,10 @@
+import { toArray } from 'util'
import { DefinedPropertiesKey } from '../WrappedObject'
import { StyledLayer } from './StyledLayer'
import { Rectangle } from '../models/Rectangle'
import { Types } from '../enums'
import { Factory } from '../Factory'
import { wrapObject } from '../wrapNativeObject'
-import { toArray } from '../utils'
import { Override } from '../models/Override'
import { ImageData } from '../models/ImageData'
diff --git a/Source/dom/layers/SymbolMaster.js b/Source/dom/layers/SymbolMaster.js
index 5f27d5dc8..4b00ad422 100644
--- a/Source/dom/layers/SymbolMaster.js
+++ b/Source/dom/layers/SymbolMaster.js
@@ -1,10 +1,10 @@
+import { toArray } from 'util'
import { DefinedPropertiesKey } from '../WrappedObject'
import { Artboard } from './Artboard'
import { Rectangle } from '../models/Rectangle'
import { Types } from '../enums'
import { Factory } from '../Factory'
import { wrapObject } from '../wrapNativeObject'
-import { toArray } from '../utils'
/**
* A Sketch symbol master.
diff --git a/Source/dom/layers/__tests__/Image.test.js b/Source/dom/layers/__tests__/Image.test.js
index b45ea3943..3b1efa756 100644
--- a/Source/dom/layers/__tests__/Image.test.js
+++ b/Source/dom/layers/__tests__/Image.test.js
@@ -10,5 +10,5 @@ test('should create an empty image', (context, document) => {
log(image)
expect(image.type).toBe('Image')
expect(image.parent).toEqual(page)
- expect(image.image).toBe(undefined)
+ expect(image.image).toBe(null)
})
diff --git a/Source/dom/layers/__tests__/Layer.test.js b/Source/dom/layers/__tests__/Layer.test.js
index 6828a10a5..bd6d7cb25 100644
--- a/Source/dom/layers/__tests__/Layer.test.js
+++ b/Source/dom/layers/__tests__/Layer.test.js
@@ -183,6 +183,27 @@ test('should lock the layer', () => {
expect(group.locked).toBe(true)
})
+test('should change the exportFormats', () => {
+ const group = new Group()
+ expect(group.exportFormats).toEqual([])
+
+ group.exportFormats = [
+ {
+ size: '2x',
+ suffix: '@2x',
+ },
+ ]
+ expect(group.exportFormats.map(e => e.toJSON())).toEqual([
+ {
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '2x',
+ },
+ ])
+})
+
test('should get the different parents', (context, document) => {
const page = document.selectedPage
expect(page.parent).toEqual(document)
diff --git a/Source/dom/layers/__tests__/Slice.test.js b/Source/dom/layers/__tests__/Slice.test.js
new file mode 100644
index 000000000..9db51ebd0
--- /dev/null
+++ b/Source/dom/layers/__tests__/Slice.test.js
@@ -0,0 +1,10 @@
+/* globals expect, test */
+
+import { Slice } from '../..'
+
+test('should create an slice', () => {
+ const slice = new Slice({ name: 'Test' })
+ // check that an artboard can be logged
+ log(slice)
+ expect(slice.type).toBe('Slice')
+})
diff --git a/Source/dom/models/Document.js b/Source/dom/models/Document.js
index 51c6e0982..03d4575e2 100644
--- a/Source/dom/models/Document.js
+++ b/Source/dom/models/Document.js
@@ -1,7 +1,8 @@
+import { toArray } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
import { Page } from '../layers/Page'
import { Selection } from './Selection'
-import { toArray, getURLFromPath } from '../utils'
+import { getURLFromPath } from '../utils'
import { wrapObject } from '../wrapNativeObject'
import { Types } from '../enums'
import { Factory } from '../Factory'
@@ -388,7 +389,7 @@ Document.define('pages', {
this._object.removePages_detachInstances(this._object.pages(), true)
toArray(pages)
- .map(wrapObject)
+ .map(p => wrapObject(p, Types.Page))
.forEach(page => {
page.parent = this // eslint-disable-line
})
diff --git a/Source/dom/models/ExportFormat.js b/Source/dom/models/ExportFormat.js
new file mode 100644
index 000000000..50ae89152
--- /dev/null
+++ b/Source/dom/models/ExportFormat.js
@@ -0,0 +1,109 @@
+import { DefinedPropertiesKey, WrappedObject } from '../WrappedObject'
+import { Types } from '../enums'
+import { Factory } from '../Factory'
+
+/**
+ * An MSExportFormat. This is not exposed, only used by the exportOptions of the Layer
+ */
+export class ExportFormat extends WrappedObject {
+ constructor(exportFormat = {}) {
+ if (!exportFormat.sketchObject) {
+ // eslint-disable-next-line no-param-reassign
+ exportFormat.sketchObject = MSExportFormat.formatWithScale_name_fileFormat(
+ 1,
+ '',
+ 'png'
+ )
+ }
+
+ super(exportFormat)
+ }
+}
+
+ExportFormat.type = Types.ExportFormat
+ExportFormat[DefinedPropertiesKey] = { ...WrappedObject[DefinedPropertiesKey] }
+Factory.registerClass(ExportFormat, MSExportFormat)
+
+delete ExportFormat[DefinedPropertiesKey].id
+
+ExportFormat.define('fileFormat', {
+ get() {
+ return String(this._object.fileFormat())
+ },
+ set(fileFormat) {
+ if (!MSExportFormat.validFormats().containsObject(fileFormat)) {
+ throw new Error('File format not supported')
+ }
+
+ this._object.setFileFormat(fileFormat)
+ },
+})
+
+ExportFormat.define('prefix', {
+ get() {
+ if (this._object.namingScheme() == 0) {
+ // we have a suffix
+ return undefined
+ }
+ return String(this._object.name())
+ },
+ set(name) {
+ this._object.setNamingScheme(1)
+ this._object.setName(name)
+ },
+})
+
+ExportFormat.define('suffix', {
+ get() {
+ if (this._object.namingScheme() == 1) {
+ // we have a prefix
+ return undefined
+ }
+ return String(this._object.name())
+ },
+ set(name) {
+ this._object.setNamingScheme(0)
+ this._object.setName(name)
+ },
+})
+
+ExportFormat.define('size', {
+ get() {
+ switch (this._object.visibleScaleType()) {
+ case 0:
+ return `${this._object.scale()}x`
+ case 1:
+ return `${this._object.absoluteSize()}w`
+ case 2:
+ return `${this._object.absoluteSize()}h`
+ default:
+ throw new Error('unknown visibleScaleType')
+ }
+ },
+ set(_size) {
+ const size = String(_size)
+ if (
+ size.endsWith('w') ||
+ size.endsWith('width') ||
+ (size.endsWith('px') && this._object.visibleScaleType() == 1)
+ ) {
+ this._object.setVisibleScaleType(1)
+ this._object.setScale(0)
+ this._object.setAbsoluteSize(parseInt(size, 10))
+ } else if (
+ size.endsWith('h') ||
+ size.endsWith('height') ||
+ (size.endsWith('px') && this._object.visibleScaleType() == 2)
+ ) {
+ this._object.setVisibleScaleType(2)
+ this._object.setScale(0)
+ this._object.setAbsoluteSize(parseInt(size, 10))
+ } else if (size.endsWith('x')) {
+ this._object.setVisibleScaleType(0)
+ this._object.setScale(parseInt(size, 10))
+ this._object.setAbsoluteSize(0)
+ } else {
+ throw new Error('could not parse the size')
+ }
+ },
+})
diff --git a/Source/dom/models/Flow.js b/Source/dom/models/Flow.js
index 77ee9305b..95785a471 100644
--- a/Source/dom/models/Flow.js
+++ b/Source/dom/models/Flow.js
@@ -1,7 +1,8 @@
+import { isNativeObject } from 'util'
import { DefinedPropertiesKey, WrappedObject } from '../WrappedObject'
import { Types } from '../enums'
import { Factory } from '../Factory'
-import { isWrappedObject, isNativeObject } from '../utils'
+import { isWrappedObject } from '../utils'
import { wrapObject } from '../wrapNativeObject'
// Mapping between animation type names and values.
diff --git a/Source/dom/models/ImageData.js b/Source/dom/models/ImageData.js
index f101d32ce..3798d1190 100644
--- a/Source/dom/models/ImageData.js
+++ b/Source/dom/models/ImageData.js
@@ -1,7 +1,8 @@
+import { isNativeObject } from 'util'
import { DefinedPropertiesKey, WrappedObject } from '../WrappedObject'
import { Types } from '../enums'
import { Factory } from '../Factory'
-import { isWrappedObject, isNativeObject } from '../utils'
+import { isWrappedObject } from '../utils'
/**
* An MSImageData. This is not exposed, only used by Image
diff --git a/Source/dom/models/Library.js b/Source/dom/models/Library.js
index 8c8cb93ed..3709f222e 100644
--- a/Source/dom/models/Library.js
+++ b/Source/dom/models/Library.js
@@ -1,6 +1,7 @@
+import { toArray } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
import { Document } from './Document'
-import { toArray, getURLFromPath, getDocumentData } from '../utils'
+import { getURLFromPath, getDocumentData } from '../utils'
import { Types } from '../enums'
import { Factory } from '../Factory'
import { wrapObject } from '../wrapNativeObject'
diff --git a/Source/dom/models/Selection.js b/Source/dom/models/Selection.js
index 744b9ad02..ea9e685de 100644
--- a/Source/dom/models/Selection.js
+++ b/Source/dom/models/Selection.js
@@ -1,4 +1,4 @@
-import { toArray } from '../utils'
+import { toArray } from 'util'
import { wrapNativeObject } from '../wrapNativeObject'
/**
diff --git a/Source/dom/models/SharedStyle.js b/Source/dom/models/SharedStyle.js
index 128a291a9..669c29fe9 100644
--- a/Source/dom/models/SharedStyle.js
+++ b/Source/dom/models/SharedStyle.js
@@ -1,8 +1,8 @@
+import { toArray } from 'util'
import { DefinedPropertiesKey, WrappedObject } from '../WrappedObject'
import { Types } from '../enums'
import { Factory } from '../Factory'
import { wrapObject } from '../wrapNativeObject'
-import { toArray } from '../utils'
const SharedStyleTypeMap = {
1: 'Layer',
diff --git a/Source/dom/models/__tests__/ExportFormat.test.js b/Source/dom/models/__tests__/ExportFormat.test.js
new file mode 100644
index 000000000..9ddf78187
--- /dev/null
+++ b/Source/dom/models/__tests__/ExportFormat.test.js
@@ -0,0 +1,132 @@
+/* globals expect, test */
+import { Slice } from '../..'
+
+test('should be able to log an ExportFormat', () => {
+ const artboard = new Slice({
+ exportFormats: [
+ {
+ size: '2x',
+ suffix: '@2x',
+ },
+ ],
+ })
+ log(artboard.exportFormats)
+ expect(artboard.exportFormats.map(e => e.toJSON())).toEqual([
+ {
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '2x',
+ },
+ ])
+})
+
+test('should be able to modify an ExportFormat', () => {
+ const artboard = new Slice({
+ exportFormats: [
+ {
+ size: '2x',
+ suffix: '@2x',
+ },
+ ],
+ })
+ const [exportFormat] = artboard.exportFormats
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '2x',
+ })
+
+ exportFormat.size = '25x'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '25x',
+ })
+
+ exportFormat.size = '500w'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '500w',
+ })
+
+ exportFormat.size = '400width'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '400w',
+ })
+
+ exportFormat.size = '300px'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '300w',
+ })
+
+ exportFormat.size = '500h'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '500h',
+ })
+
+ exportFormat.size = '400height'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '400h',
+ })
+
+ exportFormat.size = '300px'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'png',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '300h',
+ })
+
+ exportFormat.fileFormat = 'jpg'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'jpg',
+ prefix: undefined,
+ suffix: '@2x',
+ size: '300h',
+ })
+
+ exportFormat.suffix = '@3x'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'jpg',
+ prefix: undefined,
+ suffix: '@3x',
+ size: '300h',
+ })
+
+ exportFormat.prefix = '@4x'
+ expect(exportFormat.toJSON()).toEqual({
+ type: 'ExportFormat',
+ fileFormat: 'jpg',
+ prefix: '@4x',
+ suffix: undefined,
+ size: '300h',
+ })
+})
diff --git a/Source/dom/style/BorderOptions.js b/Source/dom/style/BorderOptions.js
index b6b317b10..f359bd9bf 100644
--- a/Source/dom/style/BorderOptions.js
+++ b/Source/dom/style/BorderOptions.js
@@ -1,5 +1,5 @@
+import { toArray } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
-import { toArray } from '../utils'
import { Types } from '../enums'
const ArrowheadMap = {
diff --git a/Source/dom/style/Color.js b/Source/dom/style/Color.js
index 6697dfd96..1d4f90c8d 100644
--- a/Source/dom/style/Color.js
+++ b/Source/dom/style/Color.js
@@ -1,4 +1,4 @@
-import { isNativeObject } from '../utils'
+import { isNativeObject } from 'util'
/**
* Given a string description of a color, return an MSColor.
diff --git a/Source/dom/style/Gradient.js b/Source/dom/style/Gradient.js
index 5250d73da..78cd7f365 100644
--- a/Source/dom/style/Gradient.js
+++ b/Source/dom/style/Gradient.js
@@ -1,5 +1,5 @@
+import { toArray, isNativeObject } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
-import { toArray, isNativeObject } from '../utils'
import { GradientStop } from './GradientStop'
import { Point } from '../models/Point'
import { Types } from '../enums'
diff --git a/Source/dom/style/GradientStop.js b/Source/dom/style/GradientStop.js
index 3761fddcf..28a2349f2 100644
--- a/Source/dom/style/GradientStop.js
+++ b/Source/dom/style/GradientStop.js
@@ -1,5 +1,5 @@
+import { isNativeObject } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
-import { isNativeObject } from '../utils'
import { Color, colorToString } from './Color'
import { Types } from '../enums'
diff --git a/Source/dom/style/Style.js b/Source/dom/style/Style.js
index 7f4d12305..32525067d 100644
--- a/Source/dom/style/Style.js
+++ b/Source/dom/style/Style.js
@@ -1,6 +1,6 @@
+import { toArray } from 'util'
import { WrappedObject, DefinedPropertiesKey } from '../WrappedObject'
import { Factory } from '../Factory'
-import { toArray } from '../utils'
import { wrapObject } from '../wrapNativeObject'
import { Types } from '../enums'
import { GradientType } from './Gradient'
diff --git a/Source/dom/utils.js b/Source/dom/utils.js
index d5652e5c8..f5fc4438b 100644
--- a/Source/dom/utils.js
+++ b/Source/dom/utils.js
@@ -9,21 +9,6 @@ export function getDocumentData(document) {
return documentData
}
-export function toArray(object) {
- if (Array.isArray(object)) {
- return object
- }
- const arr = []
- for (let j = 0; j < (object || []).length; j += 1) {
- arr.push(object.objectAtIndex(j))
- }
- return arr
-}
-
-export function isNativeObject(object) {
- return object && object.class && typeof object.class === 'function'
-}
-
export function isWrappedObject(object) {
return object && object._isWrappedObject
}
diff --git a/Source/dom/wrapNativeObject.js b/Source/dom/wrapNativeObject.js
index ae637a82b..12e752d81 100644
--- a/Source/dom/wrapNativeObject.js
+++ b/Source/dom/wrapNativeObject.js
@@ -1,6 +1,6 @@
+import { isNativeObject, isObject } from 'util'
import { WrappedObject } from './WrappedObject'
-
-import { isNativeObject, isWrappedObject } from './utils'
+import { isWrappedObject } from './utils'
import { Factory } from './Factory'
/**
@@ -26,12 +26,12 @@ export function wrapNativeObject(nativeObject) {
return JsClass.fromNative(nativeObject)
}
-export function wrapObject(object) {
+export function wrapObject(object, defaultType) {
if (!object) {
return undefined
}
- if (isNativeObject(object)) {
+ if (isNativeObject(object) && !isObject(object)) {
return wrapNativeObject(object)
}
if (isWrappedObject(object)) {
@@ -40,7 +40,7 @@ export function wrapObject(object) {
const { type, ...rest } = object
- if (!type) {
+ if (!type && !defaultType) {
throw new Error(
`You need to specify a "type" when creating a nested layer. Received: ${JSON.stringify(
object,
@@ -50,5 +50,5 @@ export function wrapObject(object) {
)
}
- return Factory.create(type, rest)
+ return Factory.create(type || defaultType, rest)
}
diff --git a/Source/ui/UI.js b/Source/ui/UI.js
index f026ad0dd..e7fa4582e 100644
--- a/Source/ui/UI.js
+++ b/Source/ui/UI.js
@@ -1,6 +1,5 @@
/* globals NSAlertFirstButtonReturn */
import util from 'util'
-import { isNativeObject } from '../dom/utils'
function getPluginAlertIcon() {
if (__command.pluginBundle() && __command.pluginBundle().alertIcon()) {
@@ -24,7 +23,7 @@ export function message(text, document) {
.orderedDocuments()
.firstObject()
.showMessage(text)
- } else if (isNativeObject(document)) {
+ } else if (util.isNativeObject(document)) {
document.showMessage(text)
} else {
document.sketchObject.showMessage(text)
diff --git a/docs/api/Artboard.md b/docs/api/Artboard.md
index c4ddf8ae5..58d58de2e 100644
--- a/docs/api/Artboard.md
+++ b/docs/api/Artboard.md
@@ -10,14 +10,15 @@ var Artboard = require('sketch/dom').Artboard
A Sketch artboard. It is an instance of both [Layer](#layer) and [Group](#group) so all the methods defined there are available.
-| Properties | |
-| ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Artboard. |
-| namestring | The name of the Artboard |
-| parent[Page](#page) | The page the Artboard is in. |
-| layers[Layer](#layer)[] | The layers that this component groups together. |
-| frame[Rectangle](#rectangle) | The frame of the Artboard. This is given in coordinates that are local to the parent of the layer. |
-| flowStartPointboolean | A Start Point allows you to choose where to start your prototype from. |
+| Properties | |
+| -------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Artboard. |
+| namestring | The name of the Artboard |
+| parent[Page](#page) | The page the Artboard is in. |
+| layers[Layer](#layer)[] | The layers that this component groups together. |
+| frame[Rectangle](#rectangle) | The frame of the Artboard. This is given in coordinates that are local to the parent of the layer. |
+| flowStartPointboolean | A Start Point allows you to choose where to start your prototype from. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Artboard. |
## Create a new Artboard
diff --git a/docs/api/ExportFormat.md b/docs/api/ExportFormat.md
new file mode 100644
index 000000000..e2c9138da
--- /dev/null
+++ b/docs/api/ExportFormat.md
@@ -0,0 +1,24 @@
+---
+title: Flow
+order: 208
+section: models
+---
+
+An export format associated with a layer.
+
+| Properties | |
+| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
+| fileFormatstring | The file format of the export. |
+| prefixstring / `undefined` | The prefix added to the file name. |
+| suffixstring / `undefined` | The suffix added to the file name. |
+| sizestring | The size of the export. Valid values include `2x`, `100w`, `100width`, `100px`, `300h`, `300height`. |
+
+## Valid export file formats
+
+- `jpg`
+- `png`
+- `tiff`
+- `eps`
+- `pdf`
+- `webp`
+- `svg`
diff --git a/docs/api/Group.md b/docs/api/Group.md
index 9363fd645..b97ab11b0 100644
--- a/docs/api/Group.md
+++ b/docs/api/Group.md
@@ -10,16 +10,19 @@ var Group = require('sketch/dom').Group
A group of layers. It is also an instance of [Layer](#layer) so all the methods defined there are available.
-| Properties | |
-| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Group. |
-| namestring | The name of the Group |
-| parent[Group](#group) | The group the Group is in. |
-| frame[Rectangle](#rectangle) | The frame of the Group. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the Group. |
-| style[Style](#style) | The style of the Group. |
-| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Group is linked to if any. |
-| layers[Layer](#layer)[] | The layers that this component groups together. |
+| Properties | |
+| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Group. |
+| namestring | The name of the Group |
+| parent[Group](#group) | The group the Group is in. |
+| lockedboolean | If the group is locked. |
+| hiddenboolean | If the group is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Group. This is given in coordinates that are local to the parent of the layer. |
+| flow[Flow](#flow) | The prototyping action associated with the Group. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Group. |
+| style[Style](#style) | The style of the Group. |
+| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Group is linked to if any. |
+| layers[Layer](#layer)[] | The layers that this component groups together. |
## Create a new Group
diff --git a/docs/api/HotSpot.md b/docs/api/HotSpot.md
index e6555045c..ef2442a82 100644
--- a/docs/api/HotSpot.md
+++ b/docs/api/HotSpot.md
@@ -8,15 +8,17 @@ section: layers
var HotSpot = require('sketch/dom').HotSpot
```
-A Sketch hotspot. It is an instance of both [Layer](#layer) so all the methods defined there are available.
-
-| Properties | |
-| ---------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Artboard. |
-| namestring | The name of the Artboard |
-| parent[Page](#page) | The page the Artboard is in. |
-| frame[Rectangle](#rectangle) | The frame of the Artboard. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the layer. |
+A Sketch hotspot. It is an instance of [Layer](#layer) so all the methods defined there are available.
+
+| Properties | |
+| ---------------------------------------------------------- | --------------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the HotSpot. |
+| namestring | The name of the HotSpot |
+| parent[Group](#group) | The group the HotSpot is in.. |
+| lockedboolean | If the HotSpot is locked. |
+| hiddenboolean | If the HotSpot is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the HotSpot. This is given in coordinates that are local to the parent of the HotSpot. |
+| flow[Flow](#flow) | The prototyping action associated with the HotSpot. |
## Create a new Hotspot
diff --git a/docs/api/Image.md b/docs/api/Image.md
index 3d187716f..666b20896 100644
--- a/docs/api/Image.md
+++ b/docs/api/Image.md
@@ -10,16 +10,19 @@ var Image = require('sketch/dom').Image
An image layer. It is an instance of [Layer](#layer) so all the methods defined there are available.
-| Properties | |
-| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Image. |
-| namestring | The name of the Image |
-| parent[Group](#group) | The group the Image is in. |
-| frame[Rectangle](#rectangle) | The frame of the Image. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the Image. |
-| style[Style](#style) | The style of the Image. |
-| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Image is linked to if any. |
-| image[ImageData](#imagedata) | The actual image of the layer. |
+| Properties | |
+| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Image. |
+| namestring | The name of the Image |
+| parent[Group](#group) | The group the Image is in. |
+| lockedboolean | If the Image is locked. |
+| hiddenboolean | If the Image is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Image. This is given in coordinates that are local to the parent of the layer. |
+| flow[Flow](#flow) | The prototyping action associated with the Image. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Image. |
+| style[Style](#style) | The style of the Image. |
+| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Image is linked to if any. |
+| image[ImageData](#imagedata) | The actual image of the layer. |
## Create a new Image
diff --git a/docs/api/Layer.md b/docs/api/Layer.md
index e57030742..744360469 100644
--- a/docs/api/Layer.md
+++ b/docs/api/Layer.md
@@ -4,18 +4,19 @@ order: 301
section: layers
---
-A Sketch layer. This is the base class for most of the Sketch components and defines methods to manipulate them..
-
-| Properties | |
-| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Layer. |
-| namestring | The name of the Layer |
-| parent[Group](#group) | The group the layer is in. |
-| lockedboolean | If the layer is locked. |
-| hiddenboolean | If the layer is hidden. |
-| frame[Rectangle](#rectangle) | The frame of the Layer. This is given in coordinates that are local to the parent of the layer. |
-| selectedboolean | If the layer is selected. |
-| flow[Flow](#flow) | The prototyping action associated with the layer. |
+A Sketch layer. This is the base class for most of the Sketch components and defines methods to manipulate them.
+
+| Properties | |
+| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Layer. |
+| namestring | The name of the Layer |
+| parent[Group](#group) | The group the layer is in. |
+| lockedboolean | If the layer is locked. |
+| hiddenboolean | If the layer is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Layer. This is given in coordinates that are local to the parent of the layer. |
+| selectedboolean | If the layer is selected. |
+| flow[Flow](#flow) | The prototyping action associated with the layer. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Layer. |
## Duplicate the Layer
diff --git a/docs/api/Rectangle.md b/docs/api/Rectangle.md
index 5a7fc0938..f1ff744c1 100644
--- a/docs/api/Rectangle.md
+++ b/docs/api/Rectangle.md
@@ -1,6 +1,6 @@
---
title: Rectangle
-order: 210
+order: 211
section: models
---
diff --git a/docs/api/Selection.md b/docs/api/Selection.md
index b79bd94e5..b9bc221f9 100644
--- a/docs/api/Selection.md
+++ b/docs/api/Selection.md
@@ -1,6 +1,6 @@
---
title: Selection
-order: 208
+order: 209
section: models
---
diff --git a/docs/api/Shape.md b/docs/api/Shape.md
index 1eb83067d..979807058 100644
--- a/docs/api/Shape.md
+++ b/docs/api/Shape.md
@@ -8,17 +8,20 @@ section: layers
var Shape = require('sketch/dom').Shape
```
-An image layer. It is an instance of [Layer](#layer) so all the methods defined there are available.
+A shape layer. It is an instance of [Layer](#layer) so all the methods defined there are available.
-| Properties | |
-| ---------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Shape. |
-| namestring | The name of the Shape |
-| parent[Group](#group) | The group the shape is in. |
-| frame[Rectangle](#rectangle) | The frame of the Shape. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the Shape. |
-| style[Style](#style) | The style of the Shape. |
-| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Shape is linked to if any. |
+| Properties | |
+| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Shape. |
+| namestring | The name of the Shape |
+| parent[Group](#group) | The group the shape is in. |
+| lockedboolean | If the Shape is locked. |
+| hiddenboolean | If the shape is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Shape. This is given in coordinates that are local to the parent of the layer. |
+| flow[Flow](#flow) | The prototyping action associated with the Shape. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Shape. |
+| style[Style](#style) | The style of the Shape. |
+| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Shape is linked to if any. |
## Create a new Shape
diff --git a/docs/api/Slice.md b/docs/api/Slice.md
new file mode 100644
index 000000000..5eb9b51b3
--- /dev/null
+++ b/docs/api/Slice.md
@@ -0,0 +1,22 @@
+---
+title: Layer
+order: 311
+section: layers
+---
+
+```javascript
+var Slice = require('sketch/dom').Slice
+```
+
+A Sketch slice. It is an instance of [Layer](#layer) so all the methods defined there are available.
+
+| Properties | |
+| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Slice. |
+| namestring | The name of the Slice |
+| parent[Group](#group) | The group the Slice is in. |
+| lockedboolean | If the Slice is locked. |
+| hiddenboolean | If the Slice is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Slice. This is given in coordinates that are local to the parent of the layer. |
+| selectedboolean | If the Slice is selected. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Slice. |
diff --git a/docs/api/SymbolInstance.md b/docs/api/SymbolInstance.md
index e75d0309e..4bb5f658b 100644
--- a/docs/api/SymbolInstance.md
+++ b/docs/api/SymbolInstance.md
@@ -10,17 +10,20 @@ var SymbolInstance = require('sketch/dom').SymbolInstance
A [Symbol](https://www.sketchapp.com/docs/symbols/) instance. It is an instance of [Layer](#layer) so all the methods defined there are available.
-| Properties | |
-| --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Symbol Instance object (not to be confused with `symbolId`). |
-| namestring | The name of the Symbol Instance |
-| parent[Group](#group) | The group the Symbol Instance is in. |
-| frame[Rectangle](#rectangle) | The frame of the Symbol Instance. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the Symbol. |
-| style[Style](#style) | The style of the Symbol Instance. |
-| symbolIdstring | The unique ID of the Symbol that the instance and its master share. |
-| master[SymbolMaster](#symbol-master) | The Symbol master that the instance is linked to. |
-| overrides[Override](#symbol-override)[] | The array of the overrides to modify the instance. |
+| Properties | |
+| -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Symbol Instance object (not to be confused with `symbolId`). |
+| namestring | The name of the Symbol Instance |
+| parent[Group](#group) | The group the Symbol Instance is in. |
+| lockedboolean | If the Symbol Instance is locked. |
+| hiddenboolean | If the Symbol Instance is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Symbol Instance. This is given in coordinates that are local to the parent of the layer. |
+| flow[Flow](#flow) | The prototyping action associated with the Symbol. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Symbol Instance. |
+| style[Style](#style) | The style of the Symbol Instance. |
+| symbolIdstring | The unique ID of the Symbol that the instance and its master share. |
+| master[SymbolMaster](#symbol-master) | The Symbol master that the instance is linked to. |
+| overrides[Override](#symbol-override)[] | The array of the overrides to modify the instance. |
## Create a new Symbol Instance
diff --git a/docs/api/SymbolMaster.md b/docs/api/SymbolMaster.md
index 852e6b454..078d05e80 100644
--- a/docs/api/SymbolMaster.md
+++ b/docs/api/SymbolMaster.md
@@ -10,14 +10,15 @@ var SymbolMaster = require('sketch/dom').SymbolMaster
A [Symbol](https://www.sketchapp.com/docs/symbols/) master. It is an instance of [Artboard](#artboard) (hence of [Layer](#layer) and [Group](#group)) so all the methods defined there are available.
-| Properties | |
-| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Symbol Master object (not to be confused with `symbolId`). |
-| namestring | The name of the Symbol Master |
-| parent[Group](#group) | The group the Symbol Master is in. |
-| frame[Rectangle](#rectangle) | The frame of the Symbol Master. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the Symbol. |
-| symbolIdstring | The unique ID of the Symbol that the master and its instances share. |
+| Properties | |
+| -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Symbol Master object (not to be confused with `symbolId`). |
+| namestring | The name of the Symbol Master |
+| parent[Group](#group) | The group the Symbol Master is in. |
+| frame[Rectangle](#rectangle) | The frame of the Symbol Master. This is given in coordinates that are local to the parent of the layer. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Symbol Master. |
+| layers[Layer](#layer)[] | The layers composing the Symbol Master. |
+| symbolIdstring | The unique ID of the Symbol that the master and its instances share. |
## Create a new Symbol Master
@@ -83,8 +84,8 @@ var originLibrary = master.getLibrary()
If the Symbol Master was imported from a library, the method can be used to:
-* know about it
-* get the library back
+- know about it
+- get the library back
### Returns
diff --git a/docs/api/Text.md b/docs/api/Text.md
index 662a53102..c9c5c74ba 100644
--- a/docs/api/Text.md
+++ b/docs/api/Text.md
@@ -10,20 +10,22 @@ var Text = require('sketch/dom').Text
A text layer. It is an instance of [Layer](#layer) so all the methods defined there are available.
-| Properties | |
-| -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
-| idstring | The unique ID of the Text. |
-| namestring | The name of the Text |
-| parent[Group](#group) | The group the Text is in. |
-| frame[Rectangle](#rectangle) | The frame of the Text. This is given in coordinates that are local to the parent of the layer. |
-| flow[Flow](#flow) | The prototyping action associated with the Text. |
-| style[Style](#style) | The style of the Text. |
-| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Text is linked to if any. |
-| textstring | The string value of the text layer. |
-| alignment[Alignment](#textalignment) | The alignment of the layer. |
-| verticalAlignment[VerticalAlignment](#verticalalignment) | The vertical alignment of the layer. |
-| lineSpacing[LineSpacing](#textlinespacing) | The line spacing of the layer. |
-| fixedWidthboolean | Whether the layer should have a fixed width or a flexible width. |
+| Properties | |
+| -------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
+| idstring | The unique ID of the Text. |
+| namestring | The name of the Text |
+| parent[Group](#group) | The group the Text is in. |
+| lockedboolean | If the Text is locked. |
+| hiddenboolean | If the Text is hidden. |
+| frame[Rectangle](#rectangle) | The frame of the Text. This is given in coordinates that are local to the parent of the layer. |
+| flow[Flow](#flow) | The prototyping action associated with the Text. |
+| exportFormats[ExportFormat](#exportformat)[] | The export formats of the Symbol Master. |
+| style[Style](#style) | The style of the Text. |
+| sharedStyleIdstring / null | The ID of the [SharedStyle](#sharedstyle) this Text is linked to if any. |
+| textstring | The string value of the text layer. |
+| alignment[Alignment](#textalignment) | The alignment of the layer. |
+| lineSpacing[LineSpacing](#textlinespacing) | The line spacing of the layer. |
+| fixedWidthboolean | Whether the layer should have a fixed width or a flexible width. |
## Create a new Text
diff --git a/docs/api/fromNative.md b/docs/api/fromNative.md
index 0159b6f75..986a629ef 100644
--- a/docs/api/fromNative.md
+++ b/docs/api/fromNative.md
@@ -1,6 +1,6 @@
---
title: fromNative
-order: 211
+order: 212
section: models
---
diff --git a/examples/selection-changed/package.json b/examples/selection-changed/package.json
index 8a05aa5bf..93a09fd74 100644
--- a/examples/selection-changed/package.json
+++ b/examples/selection-changed/package.json
@@ -20,7 +20,5 @@
"devDependencies": {
"@skpm/builder": "^0.4.0"
},
- "dependencies": {
- "sketch-utils": "^0.1.2"
- }
+ "dependencies": {}
}
diff --git a/examples/selection-changed/src/selection-changed.js b/examples/selection-changed/src/selection-changed.js
index 26164461d..0af059474 100644
--- a/examples/selection-changed/src/selection-changed.js
+++ b/examples/selection-changed/src/selection-changed.js
@@ -7,9 +7,8 @@
const sketch = require('sketch')
// we will also need a function to transform an NSArray into a proper JavaScript array
-// the `sketch-utils` package contains such a function so let's just use it.
-// it was installed using `npm install --save sketch-utils`
-const toArray = require('sketch-utils/to-array')
+// the `util` package contains such a function so let's just use it.
+const { toArray } = require('util')
// ### Defining The Action Handler
//
diff --git a/examples/svgo-export/package.json b/examples/svgo-export/package.json
index 7658865c2..b26bd4680 100644
--- a/examples/svgo-export/package.json
+++ b/examples/svgo-export/package.json
@@ -25,7 +25,6 @@
"@skpm/builder": "^0.5.3"
},
"dependencies": {
- "@skpm/child_process": "^0.2.3",
- "sketch-utils": "^0.1.2"
+ "@skpm/child_process": "^0.2.3"
}
}
diff --git a/examples/svgo-export/src/svgo-export.js b/examples/svgo-export/src/svgo-export.js
index afbed36c2..5b8c71dfa 100644
--- a/examples/svgo-export/src/svgo-export.js
+++ b/examples/svgo-export/src/svgo-export.js
@@ -9,9 +9,8 @@
const { execSync } = require('@skpm/child_process')
// we will also need a function to transform an NSArray into a proper JavaScript array
-// the `sketch-utils` package contains such a function so let's just use it.
-// it was installed using `npm install --save sketch-utils`
-const toArray = require('sketch-utils/to-array')
+// the `util` package contains such a function so let's just use it.
+const { toArray } = require('util')
// allows us to access the Sketch UI to post messages
const UI = require('sketch/ui')
diff --git a/package-lock.json b/package-lock.json
index c3024bc4e..7deba2038 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,18 +14,18 @@
}
},
"@babel/core": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.1.2.tgz",
- "integrity": "sha512-IFeSSnjXdhDaoysIlev//UzHZbdEmm7D0EIH2qtse9xK7mXEZQpYjs2P00XlP1qYsYvid79p+Zgg6tz1mp6iVw==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.1.5.tgz",
+ "integrity": "sha512-vOyH020C56tQvte++i+rX2yokZcRfbv/kKcw+/BCRw/cK6dvsr47aCzm8oC1XHwMSEWbqrZKzZRLzLnq6SFMsg==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
- "@babel/generator": "^7.1.2",
- "@babel/helpers": "^7.1.2",
- "@babel/parser": "^7.1.2",
+ "@babel/generator": "^7.1.5",
+ "@babel/helpers": "^7.1.5",
+ "@babel/parser": "^7.1.5",
"@babel/template": "^7.1.2",
- "@babel/traverse": "^7.1.0",
- "@babel/types": "^7.1.2",
+ "@babel/traverse": "^7.1.5",
+ "@babel/types": "^7.1.5",
"convert-source-map": "^1.1.0",
"debug": "^3.1.0",
"json5": "^0.5.0",
@@ -44,12 +44,12 @@
}
},
"@babel/generator": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.1.2.tgz",
- "integrity": "sha512-70A9HWLS/1RHk3Ck8tNHKxOoKQuSKocYgwDN85Pyl/RBduss6AKxUR7RIZ/lzduQMSYfWEM4DDBu6A+XGbkFig==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.1.5.tgz",
+ "integrity": "sha512-IO31r62xfMI+wBJVmgx0JR9ZOHty8HkoYpQAjRWUGG9vykBTlGHdArZ8zoFtpUu2gs17K7qTl/TtPpiSi6t+MA==",
"dev": true,
"requires": {
- "@babel/types": "^7.1.2",
+ "@babel/types": "^7.1.5",
"jsesc": "^2.5.1",
"lodash": "^4.17.10",
"source-map": "^0.5.0",
@@ -267,14 +267,14 @@
}
},
"@babel/helpers": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.2.tgz",
- "integrity": "sha512-Myc3pUE8eswD73aWcartxB16K6CGmHDv9KxOmD2CeOs/FaEAQodr3VYGmlvOmog60vNQ2w8QbatuahepZwrHiA==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.5.tgz",
+ "integrity": "sha512-2jkcdL02ywNBry1YNFAH/fViq4fXG0vdckHqeJk+75fpQ2OH+Az6076tX/M0835zA45E0Cqa6pV5Kiv9YOqjEg==",
"dev": true,
"requires": {
"@babel/template": "^7.1.2",
- "@babel/traverse": "^7.1.0",
- "@babel/types": "^7.1.2"
+ "@babel/traverse": "^7.1.5",
+ "@babel/types": "^7.1.5"
}
},
"@babel/highlight": {
@@ -302,9 +302,9 @@
}
},
"@babel/parser": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.1.2.tgz",
- "integrity": "sha512-x5HFsW+E/nQalGMw7hu+fvPqnBeBaIr0lWJ2SG0PPL2j+Pm9lYvCrsZJGIgauPIENx0v10INIyFjmSNUD/gSqQ==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.1.5.tgz",
+ "integrity": "sha512-WXKf5K5HT6X0kKiCOezJZFljsfxKV1FpU8Tf1A7ZpGvyd/Q4hlrJm2EwoH2onaUq3O4tLDp+4gk0hHPsMyxmOg==",
"dev": true
},
"@babel/plugin-proposal-async-generator-functions": {
@@ -443,9 +443,9 @@
}
},
"@babel/plugin-transform-block-scoping": {
- "version": "7.0.0",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.0.0.tgz",
- "integrity": "sha512-GWEMCrmHQcYWISilUrk9GDqH4enf3UmhOEbNbNrlNAX1ssH3MsS1xLOS6rdjRVPgA7XXVPn87tRkdTEoA/dxEg==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.1.5.tgz",
+ "integrity": "sha512-jlYcDrz+5ayWC7mxgpn1Wj8zj0mmjCT2w0mPIMSwO926eXBRxpEgoN/uQVRBfjtr8ayjcmS+xk2G1jaP8JjMJQ==",
"dev": true,
"requires": {
"@babel/helper-plugin-utils": "^7.0.0",
@@ -478,9 +478,9 @@
}
},
"@babel/plugin-transform-destructuring": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.1.2.tgz",
- "integrity": "sha512-cvToXvp/OsYxtEn57XJu9BvsGSEYjAh9UeUuXpoi7x6QHB7YdWyQ4lRU/q0Fu1IJNT0o0u4FQ1DMQBzJ8/8vZg==",
+ "version": "7.1.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.1.3.tgz",
+ "integrity": "sha512-Mb9M4DGIOspH1ExHOUnn2UUXFOyVTiX84fXCd+6B5iWrQg/QMeeRmSwpZ9lnjYLSXtZwiw80ytVMr3zue0ucYw==",
"dev": true,
"requires": {
"@babel/helper-plugin-utils": "^7.0.0"
@@ -566,9 +566,9 @@
}
},
"@babel/plugin-transform-modules-systemjs": {
- "version": "7.0.0",
- "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.0.0.tgz",
- "integrity": "sha512-8EDKMAsitLkiF/D4Zhe9CHEE2XLh4bfLbb9/Zf3FgXYQOZyZYyg7EAel/aT2A7bHv62jwHf09q2KU/oEexr83g==",
+ "version": "7.1.3",
+ "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.1.3.tgz",
+ "integrity": "sha512-PvTxgjxQAq4pvVUZF3mD5gEtVDuId8NtWkJsZLEJZMZAW3TvgQl1pmydLLN1bM8huHFVVU43lf0uvjQj9FRkKw==",
"dev": true,
"requires": {
"@babel/helper-hoist-variables": "^7.0.0",
@@ -743,9 +743,9 @@
}
},
"@babel/preset-env": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.1.0.tgz",
- "integrity": "sha512-ZLVSynfAoDHB/34A17/JCZbyrzbQj59QC1Anyueb4Bwjh373nVPq5/HMph0z+tCmcDjXDe+DlKQq9ywQuvWrQg==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.1.5.tgz",
+ "integrity": "sha512-pQ+2o0YyCp98XG0ODOHJd9z4GsSoV5jicSedRwCrU8uiqcJahwQiOq0asSZEb/m/lwyu6X5INvH/DSiwnQKncw==",
"dev": true,
"requires": {
"@babel/helper-module-imports": "^7.0.0",
@@ -761,7 +761,7 @@
"@babel/plugin-transform-arrow-functions": "^7.0.0",
"@babel/plugin-transform-async-to-generator": "^7.1.0",
"@babel/plugin-transform-block-scoped-functions": "^7.0.0",
- "@babel/plugin-transform-block-scoping": "^7.0.0",
+ "@babel/plugin-transform-block-scoping": "^7.1.5",
"@babel/plugin-transform-classes": "^7.1.0",
"@babel/plugin-transform-computed-properties": "^7.0.0",
"@babel/plugin-transform-destructuring": "^7.0.0",
@@ -826,26 +826,26 @@
}
},
"@babel/traverse": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.1.0.tgz",
- "integrity": "sha512-bwgln0FsMoxm3pLOgrrnGaXk18sSM9JNf1/nHC/FksmNGFbYnPWY4GYCfLxyP1KRmfsxqkRpfoa6xr6VuuSxdw==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.1.5.tgz",
+ "integrity": "sha512-eU6XokWypl0MVJo+MTSPUtlfPePkrqsF26O+l1qFGlCKWwmiYAYy2Sy44Qw8m2u/LbPCsxYt90rghmqhYMGpPA==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.0.0",
- "@babel/generator": "^7.0.0",
+ "@babel/generator": "^7.1.5",
"@babel/helper-function-name": "^7.1.0",
"@babel/helper-split-export-declaration": "^7.0.0",
- "@babel/parser": "^7.1.0",
- "@babel/types": "^7.0.0",
+ "@babel/parser": "^7.1.5",
+ "@babel/types": "^7.1.5",
"debug": "^3.1.0",
"globals": "^11.1.0",
"lodash": "^4.17.10"
}
},
"@babel/types": {
- "version": "7.1.2",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.1.2.tgz",
- "integrity": "sha512-pb1I05sZEKiSlMUV9UReaqsCPUpgbHHHu2n1piRm7JkuBkm6QxcaIzKu6FMnMtCbih/cEYTR+RGYYC96Yk9HAg==",
+ "version": "7.1.5",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.1.5.tgz",
+ "integrity": "sha512-sJeqa/d9eM/bax8Ivg+fXF7FpN3E/ZmTrWbkk6r+g7biVYfALMnLin4dKijsaqEhpd2xvOGfQTkQkD31YCVV4A==",
"dev": true,
"requires": {
"esutils": "^2.0.2",
@@ -864,9 +864,9 @@
}
},
"@nodelib/fs.stat": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz",
- "integrity": "sha512-yprFYuno9FtNsSHVlSWd+nRlmGoAbqbeCwOryP6sC/zoCjhpArcRMYp19EvpSUSizJAlsXEwJv+wcWS9XaXdMw==",
+ "version": "1.1.3",
+ "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz",
+ "integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==",
"dev": true
},
"@octokit/rest": {
@@ -908,15 +908,15 @@
}
},
"@skpm/builder": {
- "version": "0.5.10",
- "resolved": "https://registry.npmjs.org/@skpm/builder/-/builder-0.5.10.tgz",
- "integrity": "sha512-7eIERbyzVEBM5yzWzqvHKkKf5O/9dE8ZsRQXMVgbyTnKqlaXxzgdG/zr05KX2cCjDhJ5QepNhlRhRiHcd+b71w==",
+ "version": "0.5.11",
+ "resolved": "https://registry.npmjs.org/@skpm/builder/-/builder-0.5.11.tgz",
+ "integrity": "sha512-3g+FuXRA/4S+go+Py8fUmltLNehEAr1Cq/jI74Nk8nCY5FyumCXrraDbDMzviLMh9biENgdKZDx0cslLM0Qvvw==",
"dev": true,
"requires": {
"@babel/core": "^7.0.1",
"@skpm/babel-preset": "0.2.1",
"@skpm/file-loader": "^2.0.1",
- "@skpm/internal-utils": "^0.1.10",
+ "@skpm/internal-utils": "^0.1.11",
"@skpm/nib-loader": "^0.1.1",
"@skpm/timers": "^0.1.0",
"babel-loader": "^8.0.2",
@@ -1023,9 +1023,9 @@
}
},
"@skpm/internal-utils": {
- "version": "0.1.10",
- "resolved": "https://registry.npmjs.org/@skpm/internal-utils/-/internal-utils-0.1.10.tgz",
- "integrity": "sha512-CJdEMWZeBCo0USYRLwo09AZKkdXK3OufU/qdR/pzTFNOlfNBRD7aflULJwoZO//H+3RxGIoRaNljiFW0DgnsQw==",
+ "version": "0.1.11",
+ "resolved": "https://registry.npmjs.org/@skpm/internal-utils/-/internal-utils-0.1.11.tgz",
+ "integrity": "sha512-4U7mMu29lSH6b8yfbNAACr4CeiK2HNXz76wGOqsYB4vOQq7lBTXYOGD/mLWLXMqtOT+ITMNXcDD7jjpXSXza8Q==",
"dev": true,
"requires": {
"chalk": "^2.4.1",
@@ -1059,13 +1059,13 @@
}
},
"@skpm/test-runner": {
- "version": "0.3.3",
- "resolved": "https://registry.npmjs.org/@skpm/test-runner/-/test-runner-0.3.3.tgz",
- "integrity": "sha512-rV6f4s9L5EDltefwj5bg8cOUgXgj3aiS3vL3ye6SiITIIzWj1q1TxYjmbEWJV5ntw2Dpg0XLc2mxDXzBSCsg8Q==",
+ "version": "0.3.5",
+ "resolved": "https://registry.npmjs.org/@skpm/test-runner/-/test-runner-0.3.5.tgz",
+ "integrity": "sha512-P6yrW1iJmQ+LZ1Lj8aYAmKzdm0o9sNPJfcomevGMuq9T8SD18tCYHM5o60NOeLZSR3zV/RthPehJ2/iz4Qq9Lw==",
"dev": true,
"requires": {
"@skpm/builder": "^0.5.0",
- "@skpm/internal-utils": "^0.1.8",
+ "@skpm/internal-utils": "^0.1.11",
"chalk": "^2.4.1",
"chokidar": "^2.0.3",
"globby": "^8.0.1",
@@ -1778,14 +1778,14 @@
}
},
"browserslist": {
- "version": "4.1.2",
- "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.1.2.tgz",
- "integrity": "sha512-docXmVcYth9AiW5183dEe2IxnbmpXF4jiM6efGBVRAli/iDSS894Svvjenrv5NPqAJ4dEJULmT4MSvmLG9qoYg==",
+ "version": "4.3.4",
+ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.3.4.tgz",
+ "integrity": "sha512-u5iz+ijIMUlmV8blX82VGFrB9ecnUg5qEt55CMZ/YJEhha+d8qpBfOFuutJ6F/VKRXjZoD33b6uvarpPxcl3RA==",
"dev": true,
"requires": {
- "caniuse-lite": "^1.0.30000888",
- "electron-to-chromium": "^1.3.73",
- "node-releases": "^1.0.0-alpha.12"
+ "caniuse-lite": "^1.0.30000899",
+ "electron-to-chromium": "^1.3.82",
+ "node-releases": "^1.0.1"
}
},
"btoa-lite": {
@@ -1901,9 +1901,9 @@
"dev": true
},
"caniuse-lite": {
- "version": "1.0.30000889",
- "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000889.tgz",
- "integrity": "sha512-MFxcQ6x/LEEoaIhO7Zdb7Eg8YyNONN+WBnS5ERJ0li2yRw51+i4xXUNxnLaveTb/4ZoJqsWKEmlomhG2pYzlQA==",
+ "version": "1.0.30000906",
+ "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000906.tgz",
+ "integrity": "sha512-ME7JFX6h0402om/nC/8Lw+q23QvPe2ust9U0ntLmkX9F2zaGwq47fZkjlyHKirFBuq1EM+T/LXBcDdW4bvkCTA==",
"dev": true
},
"chalk": {
@@ -2666,9 +2666,9 @@
}
},
"electron-to-chromium": {
- "version": "1.3.73",
- "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.73.tgz",
- "integrity": "sha512-6PIg7v9zRoVGh6EheRF8h6Plti+3Yo/qtHobS4/Htyt53DNHmKKGFqSae1AIk0k1S4gCQvt7I2WgpbuZNcDY+g==",
+ "version": "1.3.83",
+ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.83.tgz",
+ "integrity": "sha512-DqJoDarxq50dcHsOOlMLNoy+qQitlMNbYb6wwbE0oUw2veHdRkpNrhmngiUYKMErdJ8SJ48rpJsZTQgy5SoEAA==",
"dev": true
},
"elegant-spinner": {
@@ -5609,9 +5609,9 @@
}
},
"merge2": {
- "version": "1.2.2",
- "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.2.2.tgz",
- "integrity": "sha512-bgM8twH86rWni21thii6WCMQMRMmwqqdW3sGWi9IipnVAszdLXRjwDwAnyrVXo6DuP3AjRMMttZKUB48QWIFGg==",
+ "version": "1.2.3",
+ "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.2.3.tgz",
+ "integrity": "sha512-gdUU1Fwj5ep4kplwcmftruWofEFt6lfpkkr3h860CXbAB9c3hGb55EOL2ali0Td5oebvW0E1+3Sr+Ur7XfKpRA==",
"dev": true
},
"micromatch": {
@@ -5854,9 +5854,9 @@
}
},
"node-releases": {
- "version": "1.0.0-alpha.12",
- "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.0-alpha.12.tgz",
- "integrity": "sha512-VPB4rTPqpVyWKBHbSa4YPFme3+8WHsOSpvbp0Mfj0bWsC8TEjt4HQrLl1hsBDELlp1nB4lflSgSuGTYiuyaP7Q==",
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.3.tgz",
+ "integrity": "sha512-ZaZWMsbuDcetpHmYeKWPO6e63pSXLb50M7lJgCbcM2nC/nQC3daNifmtp5a2kp7EWwYfhuvH6zLPWkrF8IiDdw==",
"dev": true,
"requires": {
"semver": "^5.3.0"
diff --git a/package.json b/package.json
index 389fbc31b..14dd96eed 100644
--- a/package.json
+++ b/package.json
@@ -26,7 +26,7 @@
},
"devDependencies": {
"@babel/preset-typescript": "^7.1.0",
- "@skpm/test-runner": "^0.3.3",
+ "@skpm/test-runner": "^0.3.5",
"@types/node": "^10.11.4",
"awesome-typescript-loader": "^5.2.1",
"babel-loader": "^8.0.4",