Giter VIP home page Giter VIP logo

aequery's People

Contributors

fusepilot avatar klustre avatar rafikhan avatar rafikhan-so avatar runegan avatar utjduo avatar vaporstack avatar zlovatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aequery's Issues

Add to npm

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


I think it would be a good idea to add AEQuery to npm. I got a project where I would like to add AEQuery as a dependency, and that would be best handled through npm.

I was thinking that we could create an npm org, but what should that be called? "aequery", "motiondesign", "aenhancers"? @zlovatt and @Klustre mentioned moving the project to GitHub, but there is already a user there called "motiondesign", so that would't work there.

Also, if aeq-ui is still going to be included as a different file, it should probably be published as its own package, and then probably be in it's own repository. But I think there should be some discussion about why it's included as its own file as I don't really think it need to be.

Anyone got any thoughts on this?

Submodules instead of objects

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


Right now in aequery there are objects for comps, layers, properties, and keys, none of which are very developed. I think they could be much more useful as submodules, like renderqueue and project, instead of how they are now where you need to create the object before using it.

Add encoding flag to lib/misc/file.js

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


Proposal below; thoughts? Would apply to readFile as well, I think.

#!javascript

	writeFile: function(filePath, contents, encoding) {
		var file = aeq.getFileObject(filePath);
		if (!file.exists) {
			var folder = new Folder( file.path );
			if ( !folder.exists ) {
				folder.create();
			}
		}
		if (!aeq.isNullOrUndefined(encoding))
			file.encoding = encoding;
		file.open("w");
		var success = file.write(contents);
		file.close();
		return success;
	}

Space in attribute values

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


It should be possible to have spaces in attribute values, e.g when trying to get a comp named "Comp 1". It would make most sense to use quotes around the attribute value to distinguish the space from a separator between attributes.

aeq("comp[name='Comp 1']")

Add 'aeq.project.getSelectedCompsOrAll()' method?

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


    /**
     * Gets selected comps, or all comps if none is selected.
     *
     * @method
     * @memberof aeq
     * @return {aeq.arrayEx}  ArrayEx of Comp objects
     */
    function getSelectedCompsOrAll () {
        var comps = aeq.project.getSelectedComps();

        if (comps.length == 1)
            comps = aeq.arrayEx(comps);

        if (aeq.isEmpty(comps))
            return aeq.getCompositions();

        return comps;
    }

aeq.thisObj !== [object global]

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


Because the aequery definition is inside a self-invoking function this refers to the function and not the global object. This is a problem because when using aeq.ui.createMainWindow() which relies on aeq.thisObj for knowing if it should create a standalone window or not.
One solution would be to pass this into the aequery defining function, but that would not work if a user puts #include "aeq.js" inside a self-invoking function, which is at least what I usually do.

How should this be solved?

Implement an 'argument checker' function?

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


currently:

foo: function (bar) {
    bar = bar || {}
}

proposal:

// in a util.js or wherever
isDefined: function (val) {
    return typeof val !== "undefined";
}

checkArg: function (val, defaultVal) {
    return aeq.isDefined(val) ? val : defaultVal;
}

// then when in use:
foo: function (bar) {
    foo = checkArg(bar, {});
}

Add 'aeq.project.getLayersDeep' method?

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


We have aeq.getItemsDeep to create a flat arrayEx of nested items in a folder. Having this for layers in a comp (and precomps) would be good.

Pass in a comp, get a flat arrayEx of all layers in the comp and precomps.

/**
 * Returns an arrayEx of all layers in comp and precomps

 * @param  {CompItem} comp   The comp to flatten.
 * @return {aeq.arrayEx}     ArrayEx with Layer objects.
 */
function getLayersDeep (comp, returnArrayEx) {
    // The returnArrayEx param is so we can skip the converting to arrayEx when
    // recursing. It is not meant to be used outside of this function.
    var layers = [];

    aeq.forEachLayer(comp, function (layer) {
        if (aeq.isPrecomp(layer))
            layers.push.apply(layers, getLayersDeep(layer.source, false));
        else
            layers.push(layer);
    });

    // Skip converting to arrayEx when function is called by it self.
    if (returnArrayEx === false)
        return layers;

    return aeq.arrayEx(layers);
}

aeq.file.joinPath breaks UNC paths

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


Input:

var root = "\\server\path";
var folder = "foo";
var result = aeq.file.joinPath(root, folder);

Desired output: "\\server\path\foo"

Actual output: "\server\path\foo"

Note: node.path.join() handles this properly

Snippet/starter function

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


I notice that when I write short snippets that it often starts with something like this:

var comp = aeq.getActiveComp()
if ( comp === null ) {
	return alert( 'No Comp selected' )
}

var layers = comp.selectedLayers
if ( !layers.length ) {
	var applyToAll = confirm( 'No layers selected, apply to all?', false )
	if ( applyToAll ) {
		layers = aeq.getLayers( comp )
	} else {
		return
	}
}

aeq.undoGroup( 'Undo Group Name', main, [ layers ] )

I think it would be nice to have a function that does all that for you. Something like:

aeq.snippet.selectedOrAllLayers( 'Undo Group Name', function( layers ) {} )

I'm wondering if that is a good solution for it, or if there something else that can be done?

Unit testing

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


Is there some way to do unit testing for extendscript? I think it is important to have a way to test all the functions, to make sure there is no errors.
I haven't done any unit testing before, so I am not sure how it should be done. Is there anyone who know how this could be done?

Selector: get project items

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


There should be a way to get items using the selector:

aeq( "item[typeName='Footage']" )

@vaporstack mentioned filtering by footage type (e.g sequences). I don't know how that would be done, might have to use an additional filter function after calling aeq('...'), as the selector only looks at attributes of the matched objects.

That might be something worth looking into, defining custom attributes to be used in the selector. For example isSequence for item types, or parentMatchName for properties.

Copy to Clipboard

Original report by Remco Janssen (Bitbucket: [Remco Janssen](https://bitbucket.org/Remco Janssen), ).


Implement system independent copy-to-clipboard:

#!javascript

function getSystemInfo() {
  var info = $.os + " AE " + app.version + "/" + app.isoLanguage;
  return info;
}

if (!isWin()) {
  system.callSystem('echo "' + getSystemInfo() + '" | pbcopy');
} else {
  // shout out to Zlovatt!
  var cmdString = 'cmd.exe /c cmd.exe /c "echo ' + myString + ' | clip"';
  system.callSystem(cmdString);
}

Further use of aeq types?

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


aeq has custom types for 'Property', 'Comp' and 'Layer' (among others). Should some of our get functions return the aeq types for these, as opposed to native AE elements?

The benefit is that it's easier to integrate into the rest of aeq, or to chain commands. The negative is that it will break existing tools, and that maybe user just wants the native property directly vs the aeq type?

aeq.Property

  • aeq.getSelectedProperties()
  • aeq.getProperties()
  • aeq.getPropertyChildren()
  • aeq.getMarkerGroup()

What about aeq.Comp?

  • aeq.getCompositions()
  • aeq.getComposition()

Or aeq.Layer

  • aeq.getLayers()
  • aeq.getSelectedLayers()
  • aeq.getSelectedLayersOrAll()

Dialog convenience buttons

Original report by vaporstack (Bitbucket: vaporstack, GitHub: vaporstack).


I'm not sure if this is easy or possible, but supplying default values "ok" "cancel" to an ESTK dialog will automatically dismiss it with the correct return value, it might be a useful convenience to provide similar functionality for createDialog? Not sure how this is implemented internally in ScriptUI but maybe worth thinking about.

Custom build locations

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


It would be handy to have a way to set custom build locations for the gulp build. When working on a project and at the same time working on aequery, it would be nice if built itself right into that project.

I don't know much about gulp so don't know how to best implement this. Anybody else think this would be useful?

ScriptUI Capitalization Consistency

Original report by vaporstack (Bitbucket: vaporstack, GitHub: vaporstack).


There are a couple of minor inconsistencies in the casing of ui/container.js -

Notably, AddEditText / AddStatictext have dissimilar casing. Easy enough to fix but probably should be done with a deprecation warning to avoid breaking existing scripts.

Recommend we use the naming and casing as described in JavaScript Tools Guide -

* AddStatictext -> AddStaticText
* AddTreeview -> AddTreeView
* AddListbox -> AddListBox* * 

A little bit annoying to decipher since the tools guide has some inconsistencies in itself, for example

#!javascript

 ProgressBar / Scrollbar

Regex in parser/selector

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


Add the possibility of getting objects by matching attributes based on a regular expression.
For Example: aeq("com[name=/main/i]") would return all comps with names containing "main".

Would this be a useful feature?

Adapt & integrate 'findCompAsLayers' function

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


Something like this--

#!javascript

    /**
     * Takes a comp and finds it as a precomp layer in other comps
     *
     * @param {CompItem} comp Comp find as layers
     * @returns {Layer[]} Array of layers whose source matches target comp
     */
    function findCompAsLayers (comp) {
        var compAsLayers = aeq.arrayEx();
        var compUsedInArray = aeq.arrayEx(comp.usedIn);
        
        if (aeq.isEmpty(compUsedInArray))
            return;

        aeq.forEach(compUsedInArray, function (usedInComp) {
            var usedInCompLayers = aeq.arrayEx(aeq.normalizeCollection(usedInComp.layers));
            var matchingLayers = usedInCompLayers.filter(function (layer) {
                return layer.source == comp;
            });
        
            compAsLayers = compAsLayers.concat(matchingLayers);
        })
    
        return compAsLayers;
    }

Integrate & adapt selectFiles function

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


Based on this by @rafikhan, adapted from something by @rendertom

Needs to be aequery-ified, and implemented as aeq.file.selectFiles();

var myFiles = selectFiles(["jsx", "theme", "someOtherExtension"], true);

function selectFiles(extensionList, multiSelect)
{
    var message = multiSelect ? "Please select multiple files" : "Please select file";

    var getFilterForFiles = function ()
    {
        var isWindows = ($.os.indexOf("Windows") != -1);

        if (isWindows) {
            return '*.' + extensionList.join(';*.');
        } else {
            var extensionListRe = '\.(' + extensionList.join('|') + ')$';
            var re = new RegExp(extensionListRe, "i");

            return function (file) {
                return file.name.match(re) || file.constructor.name === "Folder";
            };
        }
    }

    return File.openDialog(message, getFilterForFiles(), multiSelect);
}

importFiles errors

Original report by Rune Gangsø (Bitbucket: runegan, GitHub: runegan).


Currently if an error is thrown when importing multiple files with aeq.project.importFiles the import is stopped and no items, some of which could have been imported successfully, is not returned. I think it would be better to gather the errors, and let all items be imported.

The problem then becomes: what to do with the errors?

My ideal solution would be something where the items that was imported still gets returned, as I probably want to do something with them, but I still get to control what to do with the errors.

Some solutions:

  • Return an object { items, errors }
  • Store add an errors attribute to the return array
  • Add the error into the array instead of the item that should be there.
    • Good: If the files where in a particular order or are specific to the script, the script get to know which particular files was not imported.
    • Bad: You have to do if ( item instanceof Error ) for all items the array before doing what you intend.

Implement/adapt recursiveGetFiles into aeq.file

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


Something like this? Or as a flag to the existing aeq.file.getFiles() function

	/**
	 * Recursively scan folder for all files matching extension
	 *
	 * @param {Folder} folder Root folder to serach in
	 * @param {string} extension File extension to search
	 * @returns {File[]} Array of found files
	 */
	function recursiveGetFiles (folder, extension) {
		var foundItems = aeq.arrayEx();

		var folderObject = aeq.file.getFolder(folder);
		if (aeq.isNullOrUndefined(folderObject))
			return foundItems;

		var items = aeq.file.getFiles(folderObject);
		if (aeq.isNullOrUndefined(items))
			return foundItems;

		items.forEach(function (item) {
			if (aeq.isFolder(item)) {
				foundItems = foundItems.concat(recursiveGetFiles(item, extension));
			} else if (aeq.file.getExtension(item) === extension){
				foundItems.push(item);
			}
		});

		return foundItems;
	}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.