extendscript_log
Advanced tools
+1
-1
| { | ||
| "name": "extendscript_log", | ||
| "version": "1.3.0", | ||
| "version": "1.3.1", | ||
| "description": "A log constructor for Adobe ExtendScript with optional log file, and broadcasts to CEP panels with \"ExtendScript_Log\" events. UMD wrapper for cross-compatability with AMD and node.js require.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/extendscript_log.jsxinc", |
| // Include the JSON helper | ||
| #include "./helpers/JSON.jsx" | ||
| // Include the descriptor-info module | ||
| #include "../jsx/descriptor-info.jsx" | ||
| // ActionDescriptor example | ||
| var ref = new ActionReference(); | ||
| ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); | ||
| var desc = executeActionGet(ref); | ||
| /** Retrieve its properties by running the getProperties function, passing the ActionDescriptor as a param | ||
| * @param {Boolean} reference - return reference descriptors. Could slightly affect speed. Default = false. | ||
| * @param {Boolean} extended - returns extended information about the descriptor. Default = false. | ||
| * @param {Number} maxRawLimit - limits the max number of characters from a RAWTYPE descriptor. Default = 10000. | ||
| * @param {Number} maxXMPLimit - limits the max number of characters from an XMPMetadataAsUTF8 property. Default = 10000. | ||
| * @param {String} saveToFile - Saves the descriptor to a JSON file. Default = '~/Desktop/descriptor-info.json'. | ||
| */ | ||
| var descFlags = { | ||
| reference : false, | ||
| extended : false, | ||
| maxRawLimit : 10000, | ||
| maxXMPLimit : 100000, | ||
| saveToFile: '~/Desktop/descriptor-info.json' | ||
| }; | ||
| var descObject = descriptorInfo.getProperties( desc, descFlags ); | ||
| // Running in ExtendScript | ||
| $.writeln(JSON.stringify(descObject, null, 4)); | ||
| // Running in Brackets with the Brackets-to-Photoshop extension | ||
| // https://github.com/JavierAroche/brackets-to-photoshop | ||
| // Brackets-to-Photoshop extension includes the JSON helper by default | ||
| // $.writeln(descObject); |
| // Include the JSON helper | ||
| #include "./helpers/JSON.jsx" | ||
| // Include the descriptor-info module | ||
| #include "../jsx/descriptor-info.jsx" | ||
| // ActionDescriptor example | ||
| var ref = new ActionReference(); | ||
| ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); | ||
| var desc = executeActionGet(ref); | ||
| /** Retrieve its properties by running the getProperties function, passing the ActionDescriptor as a param | ||
| * @param {Boolean} reference - return reference descriptors. Could slightly affect speed. Default = false. | ||
| * @param {Boolean} extended - returns extended information about the descriptor. Default = false. | ||
| * @param {Number} maxRawLimit - limits the max number of characters from a RAWTYPE descriptor. Default = 10000. | ||
| * @param {Number} maxXMPLimit - limits the max number of characters from an XMPMetadataAsUTF8 property. Default = 10000. | ||
| * @param {String} saveToFile - Saves the descriptor to a JSON file. Default = '~/Desktop/descriptor-info.json'. | ||
| */ | ||
| var descFlags = { | ||
| reference : false, | ||
| extended : false, | ||
| maxRawLimit : 10000, | ||
| maxXMPLimit : 100000, | ||
| saveToFile: '~/Desktop/descriptor-info.json' | ||
| }; | ||
| var descObject = descriptorInfo.getProperties( desc, descFlags ); | ||
| // Running in ExtendScript | ||
| $.writeln(JSON.stringify(descObject, null, 4)); | ||
| // Running in Brackets with the Brackets-to-Photoshop extension | ||
| // https://github.com/JavierAroche/brackets-to-photoshop | ||
| // Brackets-to-Photoshop extension includes the JSON helper by default | ||
| // $.writeln(descObject); |
| /** | ||
| * JSON - from: https://github.com/douglascrockford/JSON-js | ||
| */ | ||
| if(typeof JSON!=='object'){JSON={};}(function(){'use strict';function f(n){return n<10?'0'+n:n;}function this_value(){return this.valueOf();}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};Boolean.prototype.toJSON=this_value;Number.prototype.toJSON=this_value;String.prototype.toJSON=this_value;}var cx,escapable,gap,indent,meta,rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){if(typeof rep[i]==='string'){k=rep[i];v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){escapable=/[\\\"\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'};JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.prototype.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}()); |
| /** | ||
| * | ||
| * Descriptor-Info | ||
| * JSX script to recursively get all the properties in an ActionDescriptor used in Adobe applications | ||
| * | ||
| * Author: Javier Aroche (https://github.com/JavierAroche) | ||
| * Repo: https://github.com/JavierAroche/descriptor-info | ||
| * Version: v1.1.0 | ||
| * License MIT | ||
| * | ||
| */ | ||
| /** | ||
| * Descriptor Info constructor. | ||
| * @constructor | ||
| */ | ||
| function DescriptorInfo() {} | ||
| /** | ||
| * @public | ||
| * Handler function to get Action Descriptor properties | ||
| * @param {Object} Action Descriptor | ||
| * @param {Object} Optional params object | ||
| * @param {Boolean} reference - return reference descriptors. Could slightly affect speed. Default = false. | ||
| * @param {Boolean} extended - returns extended information about the descriptor. Default = false. | ||
| * @param {Number} maxRawLimit - limits the max number of characters from a RAWTYPE descriptor. Default = 10000. | ||
| * @param {Number} maxXMPLimit - limits the max number of characters from an XMPMetadataAsUTF8 property. Default = 10000. | ||
| * @param {String} saveToFile - Saves the descriptor to a JSON file. Default = '~/Desktop/descriptor-info.json'. | ||
| */ | ||
| DescriptorInfo.prototype.getProperties = function( theDesc, params ) { | ||
| // Define params | ||
| this.descParams = { | ||
| reference : params.reference || false, | ||
| extended : params.extended || false, | ||
| maxRawLimit : params.maxRawLimit || 10000, | ||
| maxXMPLimit : params.maxXMPLimit || 10000, | ||
| saveToFile : params.saveToFile || '~/Desktop/descriptor-info.json' | ||
| }; | ||
| var descObject; | ||
| if( theDesc == '[ActionList]' ) { | ||
| descObject = this._getDescList( theDesc ); | ||
| } else { | ||
| descObject = this._getDescObject( theDesc, {} ); | ||
| } | ||
| if(params.hasOwnProperty('saveToFile')) { | ||
| this._saveToFile( descObject, this.descParams.saveToFile ); | ||
| } | ||
| return descObject; | ||
| }; | ||
| /** | ||
| * @private | ||
| * Handler function to get the items in an ActionDescriptor Object | ||
| * @param {Object} Action Descritor | ||
| * @param {Object} Empty object to return (required since it's a recursive function) | ||
| */ | ||
| DescriptorInfo.prototype._getDescObject = function( theDesc, descObject ) { | ||
| for ( var i = 0; i < theDesc.count; i++ ) { | ||
| var typeID = theDesc.getKey(i); | ||
| var descType = ( theDesc.getType( typeID ) ).toString(); | ||
| var descProperties, | ||
| descStringID = typeIDToStringID( typeID ), | ||
| descCharID = typeIDToCharID( typeID ); | ||
| if( this.descParams.extended ) { | ||
| descProperties = { | ||
| stringID : descStringID, | ||
| charID : descCharID, | ||
| id : typeID, | ||
| key : i, | ||
| type : descType, | ||
| value : this._getValue( theDesc, descType, typeID ) | ||
| }; | ||
| } else { | ||
| descProperties = this._getValue( theDesc, descType, typeID ); | ||
| } | ||
| var objectName = this._getBestName( typeID ); | ||
| switch( descType ) { | ||
| case 'DescValueType.OBJECTTYPE': | ||
| if( this.descParams.extended ) { | ||
| descProperties.object = this._getDescObject( descProperties.value, {} ); | ||
| } else { | ||
| descProperties = this._getDescObject( descProperties, {} ); | ||
| } | ||
| break; | ||
| case 'DescValueType.LISTTYPE': | ||
| if( this.descParams.extended ) { | ||
| descProperties.list = this._getDescList( descProperties.value ); | ||
| } else { | ||
| descProperties = this._getDescList( descProperties ); | ||
| } | ||
| break; | ||
| case 'DescValueType.ENUMERATEDTYPE': | ||
| descProperties.enumerationType = typeIDToStringID(theDesc.getEnumerationType( typeID )); | ||
| break; | ||
| case 'DescValueType.REFERENCETYPE': | ||
| if( this.descParams.reference ) { | ||
| var referenceValue; | ||
| if( this.descParams.extended ) { | ||
| referenceValue = descProperties.value; | ||
| } else { | ||
| referenceValue = descProperties; | ||
| } | ||
| try { | ||
| descProperties.actionReference = this._getActionReferenceInfo( referenceValue ); | ||
| } catch( err) { | ||
| $.writeln( "Unable to get value: " + descStringID + ' - ' + err ); | ||
| } | ||
| try { | ||
| descProperties.actionReferenceContainer = this._getActionReferenceInfo( referenceValue.getContainer() ); | ||
| } catch( err ) { | ||
| $.writeln( "Unable to get container: " + descStringID + ' - ' + err ); | ||
| } | ||
| try { | ||
| descProperties.reference = executeActionGet( referenceValue ); | ||
| } catch( err ) { | ||
| $.writeln( "Unable to run executeActionGet from value: " + descStringID + ' - ' + err ); | ||
| } | ||
| try { | ||
| descProperties.referenceContainer = executeActionGet( referenceValue.getContainer() ); | ||
| } catch( err ) { | ||
| $.writeln( "Unable to run executeActionGet from container: " + descStringID + ' - ' + err ); | ||
| } | ||
| } | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| descObject[objectName] = descProperties; | ||
| } | ||
| return descObject; | ||
| }; | ||
| /** | ||
| * @private | ||
| * Handler function to get the items in an ActionList | ||
| * @param {Object} Action List | ||
| */ | ||
| DescriptorInfo.prototype._getDescList = function( list ) { | ||
| var listArray = []; | ||
| for ( var ii = 0; ii < list.count; ii++ ) { | ||
| var listItemType = list.getType(ii).toString(); | ||
| var listItemValue = this._getValue( list, listItemType, ii ); | ||
| try { | ||
| switch( listItemType ) { | ||
| case 'DescValueType.OBJECTTYPE': | ||
| var listItemOBJ = {}; | ||
| var listItemProperties, | ||
| descStringID = typeIDToStringID( list.getClass(ii) ); | ||
| if( this.descParams.extended ) { | ||
| listItemProperties = { | ||
| stringID : descStringID, | ||
| key : ii, | ||
| type : listItemType, | ||
| value : listItemValue | ||
| }; | ||
| listItemProperties.object = this._getDescObject( listItemValue, {} ); | ||
| } else { | ||
| listItemProperties = this._getDescObject( listItemValue, {} ); | ||
| } | ||
| var listItemObject = {}; | ||
| listItemObject[descStringID] = listItemProperties; | ||
| listArray.push( listItemObject ); | ||
| break; | ||
| case 'DescValueType.LISTTYPE': | ||
| listArray.push( this._getDescList( listItemValue ) ); | ||
| break; | ||
| case 'DescValueType.REFERENCETYPE': | ||
| if( this.descParams.reference ) { | ||
| var referenceProperties = {}; | ||
| try { | ||
| referenceProperties.actionReference = this._getActionReferenceInfo( listItemValue ); | ||
| } catch( err) { | ||
| $.writeln( "Unable to get value: " + descStringID + ' - ' + err ); | ||
| } | ||
| try { | ||
| referenceProperties.actionReferenceContainer = this._getActionReferenceInfo( listItemValue.getContainer() ); | ||
| } catch( err ) { | ||
| $.writeln( "Unable to get container: " + descStringID + ' - ' + err ); | ||
| } | ||
| try { | ||
| referenceProperties.reference = executeActionGet( listItemValue ); | ||
| } catch( err ) { | ||
| $.writeln( "Unable to run executeActionGet from value: " + descStringID + ' - ' + err ); | ||
| } | ||
| try { | ||
| referenceProperties.referenceContainer = executeActionGet( listItemValue.getContainer() ); | ||
| } catch( err ) { | ||
| $.writeln( "Unable to run executeActionGet from container: " + descStringID + ' - ' + err ); | ||
| } | ||
| listArray.push( referenceProperties ); | ||
| } else { | ||
| listArray.push( listItemValue ); | ||
| } | ||
| break; | ||
| default: | ||
| listArray.push( listItemValue ); | ||
| break; | ||
| } | ||
| } catch( err) { | ||
| $.writeln( "Unable to get list: "+ listItemValue + " - " + err ); | ||
| } | ||
| } | ||
| return listArray; | ||
| } | ||
| /** | ||
| * @private | ||
| * | ||
| * Based on code by Michael Hale | ||
| * http://www.ps-scripts.com/ | ||
| * | ||
| * Handler function to get the value of an Action Descriptor | ||
| * @param {Object} Action Descriptor | ||
| * @param {String} Action Descriptor type | ||
| * @param {Number} Action Descriptor Key / Index | ||
| */ | ||
| DescriptorInfo.prototype._getValue = function( theDesc, descType, position ) { | ||
| switch( descType ) { | ||
| case 'DescValueType.BOOLEANTYPE': | ||
| return theDesc.getBoolean( position ); | ||
| break; | ||
| case 'DescValueType.CLASSTYPE': | ||
| return theDesc.getClass( position ); | ||
| break; | ||
| case 'DescValueType.DOUBLETYPE': | ||
| return theDesc.getDouble( position ); | ||
| break; | ||
| case 'DescValueType.ENUMERATEDTYPE': | ||
| return typeIDToStringID(theDesc.getEnumerationValue( position )); | ||
| break; | ||
| case 'DescValueType.INTEGERTYPE': | ||
| return theDesc.getInteger( position ); | ||
| break; | ||
| case 'DescValueType.LISTTYPE': | ||
| return theDesc.getList( position ); | ||
| break; | ||
| case 'DescValueType.OBJECTTYPE': | ||
| return theDesc.getObjectValue( position ); | ||
| break; | ||
| case 'DescValueType.REFERENCETYPE': | ||
| return theDesc.getReference( position ); | ||
| break; | ||
| case 'DescValueType.STRINGTYPE': | ||
| var str = ''; | ||
| if( typeIDToStringID( position ) == 'XMPMetadataAsUTF8' ) { | ||
| return str + JSON.stringify(theDesc.getString( position )).substring( 0, this.descParams.maxXMPLimit ); | ||
| } else { | ||
| return str + theDesc.getString( position ); | ||
| } | ||
| break; | ||
| case 'DescValueType.UNITDOUBLE': | ||
| return theDesc.getUnitDoubleValue( position ); | ||
| break; | ||
| case 'DescValueType.ALIASTYPE': | ||
| return decodeURI(theDesc.getPath( position )); | ||
| break; | ||
| case 'DescValueType.RAWTYPE': | ||
| return theDesc.getData( position ).substring( 0, this.descParams.maxRawLimit ); | ||
| break; | ||
| case 'ReferenceFormType.CLASSTYPE': | ||
| return theDesc.getDesiredClass(); | ||
| break; | ||
| case 'ReferenceFormType.ENUMERATED': | ||
| var enumeratedID = theDesc.getEnumeratedValue(); | ||
| return this._getBestName( enumeratedID ); | ||
| break; | ||
| case 'ReferenceFormType.IDENTIFIER': | ||
| return theDesc.getIdentifier(); | ||
| break; | ||
| case 'ReferenceFormType.INDEX': | ||
| return theDesc.getIndex(); | ||
| break; | ||
| case 'ReferenceFormType.NAME': | ||
| var str = ''; | ||
| return str + theDesc.getName(); | ||
| break; | ||
| case 'ReferenceFormType.OFFSET': | ||
| return theDesc.getOffset(); | ||
| break; | ||
| case 'ReferenceFormType.PROPERTY': | ||
| var propertyID = theDesc.getProperty(); | ||
| return this._getBestName( propertyID ); | ||
| break; | ||
| default: | ||
| break; | ||
| }; | ||
| }; | ||
| /** | ||
| * @private | ||
| * | ||
| * Handler function to get the info about action reference | ||
| * @param {Object} Action Reference | ||
| */ | ||
| DescriptorInfo.prototype._getActionReferenceInfo = function( reference ) { | ||
| var form = reference.getForm().toString(); | ||
| var classID = reference.getDesiredClass(); | ||
| var info; | ||
| if( this.descParams.extended ) { | ||
| info = { | ||
| stringID : typeIDToStringID( classID ), | ||
| charID : typeIDToCharID( classID ), | ||
| id : classID, | ||
| type : form, | ||
| value : this._getValue( reference, form, 0 ) | ||
| }; | ||
| } else { | ||
| info = this._getValue( reference, form, 0 ); | ||
| } | ||
| return info; | ||
| } | ||
| /** | ||
| * @private | ||
| * | ||
| * Handler function to get the best name for typeID | ||
| * @param {Number} typeID | ||
| */ | ||
| DescriptorInfo.prototype._getBestName = function( typeID ) { | ||
| var stringValue = typeIDToStringID( typeID ); | ||
| var charValue = typeIDToCharID( typeID ); | ||
| if( stringValue ) { | ||
| return stringValue; | ||
| } else if( charValue ) { | ||
| return charValue; | ||
| } else { | ||
| return typeID + ""; | ||
| } | ||
| } | ||
| /** | ||
| * @private | ||
| * | ||
| * Handler function to save descriptor into a file | ||
| * @param {String} descriptor | ||
| */ | ||
| DescriptorInfo.prototype._saveToFile = function( descriptor, outputFile ) { | ||
| outputFile = File(outputFile); | ||
| if(outputFile.exists) { | ||
| outputFile.remove(); | ||
| } | ||
| outputFile.encoding = "UTF8"; | ||
| outputFile.open( "e", "TEXT", "????" ); | ||
| outputFile.writeln( JSON.stringify(descriptor, null, 4) ); | ||
| outputFile.close(); | ||
| } | ||
| // Create a new Descriptor instance | ||
| var descriptorInfo = new DescriptorInfo(); |
| MIT License | ||
| Copyright (c) 2016 Javier Aroche | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
| # Descriptor Info | ||
| [](https://github.com/JavierAroche/parse-action-descriptor-code) | ||
| ## Description | ||
| JSX module to recursively get all the properties in an `ActionDescriptor` used in Adobe applications. | ||
| ## Usage | ||
| **getProperties** | ||
| Return complete Descriptor info in JSON format | ||
| ```javascript | ||
| /** | ||
| * @param {Boolean} reference - return reference descriptors. Could slightly affect speed. Default = false. | ||
| * @param {Boolean} extended - returns extended information about the descriptor. Default = false. | ||
| * @param {Number} maxRawLimit - limits the max number of characters from a RAWTYPE descriptor. Default = 10000. | ||
| * @param {Number} maxXMPLimit - limits the max number of characters from an XMPMetadataAsUTF8 property. Default = 10000. | ||
| * @param {String} saveToFile - Saves the descriptor to a JSON file. Default = '~/Desktop/descriptor-info.json'. | ||
| */ | ||
| ``` | ||
| **Sample code for getting Descriptor properties with getProperties** | ||
| ```javascript | ||
| // Include the JSON helper | ||
| #include "./helpers/JSON.jsx" | ||
| // Include the descriptor-info module | ||
| #include "../jsx/descriptor-info.jsx" | ||
| // ActionDescriptor example | ||
| var ref = new ActionReference(); | ||
| ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); | ||
| var desc = executeActionGet(ref); | ||
| // Optional | ||
| var descFlags = { | ||
| reference : false, | ||
| extended : false, | ||
| maxRawLimit : 10000, | ||
| maxXMPLimit : 100000, | ||
| saveToFile: '~/Desktop/descriptor-info.json' | ||
| }; | ||
| // Retrieve its properties by running the getProperties function, passing the ActionDescriptor as a param | ||
| var descObject = descriptorInfo.getProperties( desc, descFlags ); | ||
| ``` | ||
| **JSON returned for requested Descriptor info.** | ||
| ```javascript | ||
| { | ||
| "name": "Layer 0", | ||
| "color": "none", | ||
| "visible": true, | ||
| "mode": "normal", | ||
| "opacity": 255, | ||
| "layerID": 4, | ||
| "itemIndex": 2, | ||
| "count": 3, | ||
| "preserveTransparency": false, | ||
| "layerFXVisible": false, | ||
| "globalAngle": 30, | ||
| "background": false, | ||
| "layerSection": "layerSectionContent", | ||
| "layerLocking": { | ||
| "protectTransparency": false, | ||
| "protectComposite": false, | ||
| "protectPosition": false, | ||
| "protectAll": false | ||
| }, | ||
| "group": false, | ||
| "targetChannels": [ | ||
| { | ||
| "typename": "ActionReference" | ||
| }, | ||
| { | ||
| "typename": "ActionReference" | ||
| }, | ||
| { | ||
| "typename": "ActionReference" | ||
| } | ||
| ], | ||
| "visibleChannels": [ | ||
| { | ||
| "typename": "ActionReference" | ||
| }, | ||
| { | ||
| "typename": "ActionReference" | ||
| }, | ||
| { | ||
| "typename": "ActionReference" | ||
| } | ||
| ], | ||
| "channelRestrictions": [ | ||
| "red", | ||
| "grain", | ||
| "blue" | ||
| ], | ||
| "fillOpacity": 255, | ||
| "hasUserMask": false, | ||
| "hasVectorMask": false, | ||
| "proportionalScaling": false, | ||
| "layerKind": 5, | ||
| "hasFilterMask": false, | ||
| "userMaskDensity": 255, | ||
| "userMaskFeather": 0, | ||
| "vectorMaskDensity": 255, | ||
| "vectorMaskFeather": 0, | ||
| "bounds": { | ||
| "top": -51, | ||
| "left": -104, | ||
| "bottom": 1599, | ||
| "right": 2312, | ||
| "width": 2416, | ||
| "height": 1650 | ||
| }, | ||
| "boundsNoEffects": { | ||
| "top": -51, | ||
| "left": -104, | ||
| "bottom": 1599, | ||
| "right": 2312, | ||
| "width": 2416, | ||
| "height": 1650 | ||
| }, | ||
| "smartObject": { | ||
| "placed": "rasterizeContent", | ||
| "documentID": "", | ||
| "compsList": { | ||
| "compID": -1, | ||
| "originalCompID": -1 | ||
| }, | ||
| "linked": false, | ||
| "fileReference": "Screen Shot 2017-01-13 at 12.52.30 PM.png" | ||
| }, | ||
| "useAlignedRendering": false, | ||
| "generatorSettings": { | ||
| }, | ||
| "keyOriginType": [ | ||
| ], | ||
| "fillEnabled": false, | ||
| "animationProtection": { | ||
| "animationUnifyPosition": false, | ||
| "animationUnifyEffects": false, | ||
| "animationUnifyVisibility": false, | ||
| "animationPropagate": true | ||
| }, | ||
| "artboard": { | ||
| "artboardRect": { | ||
| "top": 0, | ||
| "left": 0, | ||
| "bottom": 0, | ||
| "right": 0 | ||
| } | ||
| }, | ||
| "artboardEnabled": false | ||
| } | ||
| ``` | ||
| **JSON returned with `extended: true`** | ||
| ```javascript | ||
| { | ||
| "name": { | ||
| "stringID": "name", | ||
| "charID": "Nm ", | ||
| "id": 1315774496, | ||
| "key": 0, | ||
| "type": "DescValueType.STRINGTYPE", | ||
| "value": "Layer 0" | ||
| }, | ||
| "color": { | ||
| "stringID": "color", | ||
| "charID": "Clr ", | ||
| "id": 1131180576, | ||
| "key": 1, | ||
| "type": "DescValueType.ENUMERATEDTYPE", | ||
| "value": "none", | ||
| "enumerationType": "color" | ||
| }, | ||
| "visible": { | ||
| "stringID": "visible", | ||
| "charID": "Vsbl", | ||
| "id": 1450402412, | ||
| "key": 2, | ||
| "type": "DescValueType.BOOLEANTYPE", | ||
| "value": true | ||
| }, | ||
| "mode": { | ||
| "stringID": "mode", | ||
| "charID": "Md ", | ||
| "id": 1298407456, | ||
| "key": 3, | ||
| "type": "DescValueType.ENUMERATEDTYPE", | ||
| "value": "normal", | ||
| "enumerationType": "blendMode" | ||
| }, | ||
| "opacity": { | ||
| "stringID": "opacity", | ||
| "charID": "Opct", | ||
| "id": 1332765556, | ||
| "key": 4, | ||
| "type": "DescValueType.INTEGERTYPE", | ||
| "value": 255 | ||
| }, | ||
| "layerID": { | ||
| "stringID": "layerID", | ||
| "charID": "LyrI", | ||
| "id": 1283027529, | ||
| "key": 5, | ||
| "type": "DescValueType.INTEGERTYPE", | ||
| "value": 4 | ||
| }, | ||
| "itemIndex": { | ||
| "stringID": "itemIndex", | ||
| "charID": "ItmI", | ||
| "id": 1232366921, | ||
| "key": 6, | ||
| "type": "DescValueType.INTEGERTYPE", | ||
| "value": 2 | ||
| }, | ||
| "targetChannels": { | ||
| "stringID": "targetChannels", | ||
| "charID": "", | ||
| "id": 3036, | ||
| "key": 15, | ||
| "type": "DescValueType.LISTTYPE", | ||
| "value": { | ||
| "count": 3, | ||
| "typename": "ActionList" | ||
| }, | ||
| "list": [ | ||
| { | ||
| "typename": "ActionReference" | ||
| }, | ||
| { | ||
| "typename": "ActionReference" | ||
| }, | ||
| { | ||
| "typename": "ActionReference" | ||
| } | ||
| ] | ||
| }, | ||
| "channelRestrictions": { | ||
| "stringID": "channelRestrictions", | ||
| "charID": "", | ||
| "id": 1196, | ||
| "key": 17, | ||
| "type": "DescValueType.LISTTYPE", | ||
| "value": { | ||
| "count": 3, | ||
| "typename": "ActionList" | ||
| }, | ||
| "list": [ | ||
| "red", | ||
| "grain", | ||
| "blue" | ||
| ] | ||
| }, | ||
| "smartObject": { | ||
| "stringID": "smartObject", | ||
| "charID": "", | ||
| "id": 829, | ||
| "key": 30, | ||
| "type": "DescValueType.OBJECTTYPE", | ||
| "value": { | ||
| "count": 5, | ||
| "typename": "ActionDescriptor" | ||
| }, | ||
| "object": { | ||
| "placed": { | ||
| "stringID": "placed", | ||
| "charID": "", | ||
| "id": 2363, | ||
| "key": 0, | ||
| "type": "DescValueType.ENUMERATEDTYPE", | ||
| "value": "rasterizeContent", | ||
| "enumerationType": "placed" | ||
| }, | ||
| "documentID": { | ||
| "stringID": "documentID", | ||
| "charID": "DocI", | ||
| "id": 1148150601, | ||
| "key": 1, | ||
| "type": "DescValueType.STRINGTYPE", | ||
| "value": "" | ||
| }, | ||
| "compsList": { | ||
| "stringID": "compsList", | ||
| "charID": "", | ||
| "id": 3017, | ||
| "key": 2, | ||
| "type": "DescValueType.OBJECTTYPE", | ||
| "value": { | ||
| "count": 2, | ||
| "typename": "ActionDescriptor" | ||
| }, | ||
| "object": ... | ||
| }, | ||
| "linked": { | ||
| "stringID": "linked", | ||
| "charID": "Lnkd", | ||
| "id": 1282304868, | ||
| "key": 3, | ||
| "type": "DescValueType.BOOLEANTYPE", | ||
| "value": false | ||
| }, | ||
| "fileReference": { | ||
| "stringID": "fileReference", | ||
| "charID": "FilR", | ||
| "id": 1181314130, | ||
| "key": 4, | ||
| "type": "DescValueType.STRINGTYPE", | ||
| "value": "Screen Shot 2017-01-13 at 12.52.30 PM.png" | ||
| } | ||
| } | ||
| }, | ||
| ... | ||
| } | ||
| ``` | ||
| ## Example | ||
| [descriptor-info-example](https://github.com/JavierAroche/descriptor-info/tree/master/example) | ||
| ## Supported Descriptors | ||
| * `DescValueType.BOOLEANTYPE` | ||
| * `DescValueType.CLASSTYPE` | ||
| * `DescValueType.DOUBLETYPE` | ||
| * `DescValueType.ENUMERATEDTYPE` | ||
| * `DescValueType.INTEGERTYPE` | ||
| * `DescValueType.LISTTYPE` | ||
| * `DescValueType.OBJECTTYPE` | ||
| * `DescValueType.REFERENCETYPE` | ||
| * `DescValueType.STRINGTYPE` | ||
| * `DescValueType.UNITDOUBLE` | ||
| * `DescValueType.ALIASTYPE` | ||
| * `DescValueType.RAWTYPE` | ||
| ## Known Limitations | ||
| * `REFERENCETYPE` Descriptors will only return the Descriptor linked, but not it's actual properties. Adding this without properly testing can fall in an endless loop. | ||
| * `RAWTYPE` Descriptors, usually labeled `legacyContentData`, will return the value as unicode. You will have to parse it separately as the data varies too much. | ||
| ## Changelog | ||
| **v1.1.0 (Dec 08 2017)** | ||
| * Added maxRawLimit param | ||
| * Added maxXMPLimit param | ||
| * Added saveToFile param | ||
| * Improved ActionReference / ActionLists | ||
| **v1.0.2 (Jan 13 2017)** | ||
| * Added optional params to retrieve extended descriptor information | ||
| * Updated example to reflect new optional params | ||
| **v1.0.1 (Jan 3 2017)** | ||
| * Added optional params to retrieve reference descriptors | ||
| * Updated example to reflect new optional params | ||
| **v1.0.0 (Dec 2 2016)** | ||
| * Added descriptor-info JSX | ||
| **v0.0.0 (Dec 2 2016)** | ||
| * Initial Commit | ||
| ## License | ||
| MIT © Javier Aroche |
Sorry, the diff of this file is not supported yet
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1
-50%0
-100%23121
-65.45%4
-63.64%0
-100%