<NME> get-shadows.cocoascript
<BEF> var getShadows = function(layer) {
	var collection = [[layer style] shadows]
	return getBothShadows(layer, collection)
}

var getInners = function(layer) {
	var collection = [[layer style] innerShadows]
	return getBothShadows(layer, collection)
}


var getBothShadows = function(layer, shadowsCollection) {
	var enabledShadows = []

	for (var s = shadowsCollection.count() - 1; s >= 0; s--) {
		var localShadow = [shadowsCollection objectAtIndex: s]
		var localHexValue = createHexString([[localShadow color] red], [[localShadow color] green], [[localShadow color] blue])
		var shadowParams = [[localShadow offsetX],[localShadow offsetY], [localShadow blurRadius], [localShadow spread], [[localShadow color] alpha], localHexValue]
		enabledShadows.push(shadowParams)
		}
	}
	
	return enabledShadows
}

<MSG> Introducing optimal export

Big fixes to Layer:
- generates Title Layer with static properties
- generate states with changing properties
- various changes in exporting logic

Tests passed: 14 of 24

<DFF> @@ -1,9 +1,13 @@
 var getShadows = function(layer) {
+	if (layer == nil) { return nil }
+	
 	var collection = [[layer style] shadows]
 	return getBothShadows(layer, collection)
 }
 
 var getInners = function(layer) {
+	if (layer == nil) { return nil }
+	
 	var collection = [[layer style] innerShadows]
 	return getBothShadows(layer, collection)
 }
@@ -20,5 +24,6 @@ var getBothShadows = function(layer, shadowsCollection) {
 		}
 	}
 	
+	if (enabledShadows == '') { return nil }
 	return enabledShadows
 }

Introducing optimal export