@nexrender/core 1.49.1 → 1.49.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/helpers/autofind.js +17 -7
- package/src/tasks/render.js +14 -12
- package/test/workpath/svBjjvo3KlgodQHqNFtPg/6snca47joec.txt +1 -0
- package/test/workpath/svBjjvo3KlgodQHqNFtPg/nexrender-svBjjvo3KlgodQHqNFtPg-script.jsx +266 -0
- package/test/workpath/svBjjvo3KlgodQHqNFtPg/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==.png +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexrender/core",
|
|
3
|
-
"version": "1.49.
|
|
3
|
+
"version": "1.49.3",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"author": "Inlife",
|
|
6
6
|
"homepage": "https://www.nexrender.com",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "06db22fa02101417e0e6574d97a07b950c5ac3c4"
|
|
42
42
|
}
|
package/src/helpers/autofind.js
CHANGED
|
@@ -80,13 +80,8 @@ const defaultPaths = {
|
|
|
80
80
|
],
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* (using a table of predefined paths)
|
|
86
|
-
* @param {Object} settings
|
|
87
|
-
* @return {String|null}
|
|
88
|
-
*/
|
|
89
|
-
module.exports = settings => {
|
|
83
|
+
|
|
84
|
+
const findAll = settings => {
|
|
90
85
|
let platform = os.platform()
|
|
91
86
|
|
|
92
87
|
if (settings.wsl) platform = 'wsl'
|
|
@@ -100,6 +95,21 @@ module.exports = settings => {
|
|
|
100
95
|
.map(folderPath => path.join(folderPath, binary))
|
|
101
96
|
.filter(binaryPath => fs.existsSync(binaryPath))
|
|
102
97
|
|
|
98
|
+
return results
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Attemnt to find a aebinary path automatically
|
|
103
|
+
* (using a table of predefined paths)
|
|
104
|
+
* @param {Object} settings
|
|
105
|
+
* @return {String|null}
|
|
106
|
+
*/
|
|
107
|
+
module.exports = settings => {
|
|
108
|
+
const results = findAll(settings)
|
|
109
|
+
|
|
103
110
|
// return first matched result
|
|
104
111
|
return results.length ? results[0] : null;
|
|
105
112
|
}
|
|
113
|
+
|
|
114
|
+
module.exports.defaultPaths = defaultPaths
|
|
115
|
+
module.exports.findAll = findAll
|
package/src/tasks/render.js
CHANGED
|
@@ -187,18 +187,7 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
|
|
|
187
187
|
|
|
188
188
|
let timeoutID = 0;
|
|
189
189
|
let updateTimeout = 0;
|
|
190
|
-
|
|
191
|
-
const updateTimeoutInterval = setInterval(() => {
|
|
192
|
-
if (projectStart === null) return;
|
|
193
|
-
|
|
194
|
-
const now = Date.now()
|
|
195
|
-
if (now - updateTimeout > settings.maxUpdateTimeout * 1000) {
|
|
196
|
-
clearInterval(updateTimeoutInterval);
|
|
197
|
-
clearTimeout(timeoutID);
|
|
198
|
-
settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_no_update' });
|
|
199
|
-
reject(new Error(`No update from aerender for ${settings.maxUpdateTimeout} seconds`));
|
|
200
|
-
}
|
|
201
|
-
}, 5000)
|
|
190
|
+
let updateTimeoutInterval = null;
|
|
202
191
|
|
|
203
192
|
if (settings.debug) {
|
|
204
193
|
settings.logger.log(`[${job.uid}] spawning aerender process: ${settings.binary} ${params.join(' ')}`);
|
|
@@ -231,6 +220,19 @@ Estimated date of change to the new behavior: 2023-06-01.\n`);
|
|
|
231
220
|
updateTimeout = Date.now()
|
|
232
221
|
});
|
|
233
222
|
|
|
223
|
+
updateTimeoutInterval = setInterval(() => {
|
|
224
|
+
if (projectStart === null) return;
|
|
225
|
+
|
|
226
|
+
const now = Date.now()
|
|
227
|
+
if (now - updateTimeout > settings.maxUpdateTimeout * 1000) {
|
|
228
|
+
clearInterval(updateTimeoutInterval);
|
|
229
|
+
clearTimeout(timeoutID);
|
|
230
|
+
settings.trackSync('Job Render Failed', { job_id: job.uid, error: 'aerender_no_update' });
|
|
231
|
+
reject(new Error(`No update from aerender for ${settings.maxUpdateTimeout} seconds`));
|
|
232
|
+
instance.kill('SIGINT');
|
|
233
|
+
}
|
|
234
|
+
}, 5000)
|
|
235
|
+
|
|
234
236
|
if (settings.maxRenderTimeout && settings.maxRenderTimeout > 0) {
|
|
235
237
|
const timeout = 1000 * settings.maxRenderTimeout;
|
|
236
238
|
timeoutID = setTimeout(
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Hello, World!
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
|
|
2
|
+
try{Object.defineProperty({},'a',{value:0})}catch(err){(function(){var defineProperty=Object.defineProperty;Object.defineProperty=function(object,property,descriptor){delete descriptor.configurable;delete descriptor.enumerable;delete descriptor.writable;try{return defineProperty(object,property,descriptor)}catch(err){object[property]=descriptor.value}}}())}Object.defineProperties||(Object.defineProperties=function defineProperties(object,descriptors){var property;for(property in descriptors){Object.defineProperty(object,property,descriptors[property])}return object});var lambda=function(l){var fn=l.match(/((.*))s*=>s*(.*)/);var p=[];var b="";if(fn.length>0){fn.shift()}if(fn.length>0){b=fn.pop()}if(fn.length>0){p=fn.pop().replace(/^s*|s(?=s)|s*$|,/g,'').split(' ')}fn=((!/s*returns+/.test(b))?"return ":"")+b;p.push(fn);try{return Function.apply({},p)}catch(e){return null}};if(typeof(Array.prototype.where)==='undefined'){Array.prototype.where=function(f){var fn=f;if(typeof f=="string"){if((fn=lambda(fn))===null){throw "Syntax error in lambda string: "+f}}var res=[];var l=this.length;var p=[0,0,res];for(var i=1;i<arguments.length;i+=1){p.push(arguments[i])}for(var j=0;j<l;j+=1){if(typeof this[j]=="undefined"){continue}p[0]=this[j];p[1]=j;if(!!fn.apply(this,p)){res.push(this[j])}}return res}}if(!Array.prototype.forEach){Array.prototype.forEach=function(callback,thisArg){var T,k;if(this===null){throw new TypeError(' this is null or not defined')}var O=Object(this);var len=O.length>>>0;if(typeof callback!=="function"){throw new TypeError(callback+' is not a function')}if(arguments.length>1){T=thisArg}k=0;while(k<len){var kValue;if(k in O){kValue=O[k];callback.call(T,kValue,k,O)}k+=1}}}if(!Array.prototype.filter){Array.prototype.filter=function(fun ){'use strict';if(this===void 0||this===null){throw new TypeError()}var t=Object(this);var len=t.length>>>0;if(typeof fun!=='function'){throw new TypeError()}var res=[];var thisArg=arguments.length>=2?arguments[1]:void 0;for(var i=0;i<len;i+=1){if(i in t){var val=t[i];if(fun.call(thisArg,val,i,t)){res.push(val)}}}return res}}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(searchElement,fromIndex){var k;if(this===null){throw new TypeError('"this" is null or not defined')}var O=Object(this);var len=O.length>>>0;if(len===0){return -1}var n= +fromIndex||0;if(Math.abs(n)===Infinity){n=0}if(n>=len){return -1}k=Math.max(n>=0?n:len-Math.abs(n),0);while(k<len){var kValue;if(k in O&&O[k]===searchElement){return k}k+=1}return -1}}if(typeof(String.prototype.localeCompare)==='undefined'){String.prototype.localeCompare=function(str,locale,options){return((this==str)?0:((this>str)?1:-1))}}
|
|
3
|
+
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
|
|
4
|
+
"use strict";
|
|
5
|
+
|
|
6
|
+
/* start of nexrender script */
|
|
7
|
+
|
|
8
|
+
var nexrender = {
|
|
9
|
+
renderCompositionName: 'test',
|
|
10
|
+
defaultCompositionName: '*',
|
|
11
|
+
types: [CompItem, FolderItem, FootageItem, AVLayer, ShapeLayer, TextLayer, CameraLayer, LightLayer, Property, PropertyGroup],
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
nexrender.typesMatch = function (types, layer) {
|
|
15
|
+
return nexrender.types.filter(function (t) {
|
|
16
|
+
return layer instanceof t;
|
|
17
|
+
}).length > 0;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
nexrender.replaceFootage = function (layer, filepath, sequence, removeOldFootage) {
|
|
21
|
+
if (!layer) { return false; }
|
|
22
|
+
|
|
23
|
+
var file = new File(filepath);
|
|
24
|
+
|
|
25
|
+
if (!file.exists) {
|
|
26
|
+
throw new Error("nexrender: Trying to create a file replacement for an unknown file: " + filepath);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
var importOptions = new ImportOptions(file);
|
|
30
|
+
|
|
31
|
+
if (sequence) { importOptions.sequence = true;}
|
|
32
|
+
var theImport = app.project.importFile(importOptions);
|
|
33
|
+
|
|
34
|
+
var oldFootage = layer.source || null;
|
|
35
|
+
|
|
36
|
+
layer.replaceSource(theImport, true);
|
|
37
|
+
|
|
38
|
+
if (removeOldFootage && oldFootage) oldFootage.remove();
|
|
39
|
+
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
/* invoke callback for every composition matching specific name */
|
|
45
|
+
nexrender.selectCompositionsByName = function(name, callback) {
|
|
46
|
+
var items = [];
|
|
47
|
+
var nameChain = name.split("->");
|
|
48
|
+
var name = nameChain.pop();
|
|
49
|
+
|
|
50
|
+
function isNestedComp(comp, name, parentChain) {
|
|
51
|
+
if (
|
|
52
|
+
name &&
|
|
53
|
+
comp.name === name &&
|
|
54
|
+
parentChain &&
|
|
55
|
+
parentChain.length > 0 &&
|
|
56
|
+
comp.usedIn.length > 0
|
|
57
|
+
) {
|
|
58
|
+
var parentComp = null;
|
|
59
|
+
for (var i = 0; i < comp.usedIn.length; i++) {
|
|
60
|
+
if (
|
|
61
|
+
comp.usedIn[i] instanceof CompItem &&
|
|
62
|
+
comp.usedIn[i].name === parentChain[parentChain.length - 1]
|
|
63
|
+
) {
|
|
64
|
+
parentComp = comp.usedIn[i];
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (parentComp) {
|
|
70
|
+
if (parentChain.length === 1) {
|
|
71
|
+
return true;
|
|
72
|
+
} else {
|
|
73
|
+
return isNestedComp(
|
|
74
|
+
parentComp,
|
|
75
|
+
parentChain.pop(),
|
|
76
|
+
parentChain
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* step 1: collect all matching compositions */
|
|
85
|
+
var len = app.project.items.length;
|
|
86
|
+
for (var i = 1; i <= len; i++) {
|
|
87
|
+
var item = app.project.items[i];
|
|
88
|
+
if (!(item instanceof CompItem)) continue;
|
|
89
|
+
|
|
90
|
+
if (name !== "*" && item.name !== name) {
|
|
91
|
+
continue;
|
|
92
|
+
} else if (nameChain.length === 0) { // if the comp name wasn't hierarchical
|
|
93
|
+
items.push(item);
|
|
94
|
+
} else if (isNestedComp(item, name, nameChain)) { // otherwise only add the comp if it matches the hierarchical position defined in the comp name
|
|
95
|
+
items.push(item);
|
|
96
|
+
} else {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* step 2: invoke callback for every match */
|
|
102
|
+
var len = items.length;
|
|
103
|
+
for (var i = 0; i < len; i++) {
|
|
104
|
+
callback(items[i]);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (len == 0) {
|
|
108
|
+
throw new Error("nexrender: Couldn't find any compositions by provided name (" + name + ")");
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/* call callback for an every layer matching specific name and composition */
|
|
113
|
+
nexrender.selectLayersByName = function(compositionName, name, callback, types, continueOnMissing) {
|
|
114
|
+
var foundOnce = false;
|
|
115
|
+
|
|
116
|
+
if (!compositionName) compositionName = nexrender.defaultCompositionName;
|
|
117
|
+
if (!types) types = nexrender.types;
|
|
118
|
+
|
|
119
|
+
nexrender.selectCompositionsByName(compositionName, function(comp) {
|
|
120
|
+
var items = [];
|
|
121
|
+
|
|
122
|
+
/* step 1: collect all matching layers */
|
|
123
|
+
for (var j = 1; j <= comp.numLayers; j++) {
|
|
124
|
+
var layer = comp.layer(j);
|
|
125
|
+
if (layer.name !== name) continue;
|
|
126
|
+
|
|
127
|
+
if (nexrender.typesMatch(types, layer)) {
|
|
128
|
+
foundOnce = true;
|
|
129
|
+
items.push(layer);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* step 2: invoke callback for every match */
|
|
134
|
+
var len = items.length;
|
|
135
|
+
for (var i = 0; i < len; i++) {
|
|
136
|
+
callback(items[i], name);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
if (!foundOnce && !continueOnMissing) {
|
|
141
|
+
throw new Error("nexrender: Couldn't find any layers by provided name (" + name + ") inside a composition: " + compositionName);
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/* call callback for every layer matching specific type and composition */
|
|
146
|
+
nexrender.selectLayersByType = function(
|
|
147
|
+
compositionName,
|
|
148
|
+
type,
|
|
149
|
+
callback,
|
|
150
|
+
types,
|
|
151
|
+
continueOnMissing
|
|
152
|
+
) {
|
|
153
|
+
var foundOnce = false;
|
|
154
|
+
|
|
155
|
+
if (!compositionName) compositionName = nexrender.defaultCompositionName;
|
|
156
|
+
if (!types) types = nexrender.types;
|
|
157
|
+
|
|
158
|
+
nexrender.selectCompositionsByName(compositionName, function(comp) {
|
|
159
|
+
var items = [];
|
|
160
|
+
|
|
161
|
+
/* step 1: collect all matching layers */
|
|
162
|
+
for (var j = 1; j <= comp.numLayers; j++) {
|
|
163
|
+
var layer = comp.layer(j);
|
|
164
|
+
|
|
165
|
+
if (!(layer instanceof type)) continue;
|
|
166
|
+
|
|
167
|
+
if (nexrender.typesMatch(types, layer)) {
|
|
168
|
+
foundOnce = true;
|
|
169
|
+
items.push(layer);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/* step 2: invoke callback for every match */
|
|
174
|
+
var len = items.length;
|
|
175
|
+
for (var i = 0; i < len; i++) {
|
|
176
|
+
callback(items[i]);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
if (!foundOnce && !continueOnMissing) {
|
|
181
|
+
throw new Error(
|
|
182
|
+
"nexrender: Couldn't find any layers by provided type ("
|
|
183
|
+
+ type +
|
|
184
|
+
") inside a composition: "
|
|
185
|
+
+ compositionName
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/* call callback for an every layer matching specific index and composition */
|
|
191
|
+
nexrender.selectLayersByIndex = function(compositionName, index, callback, types, continueOnMissing) {
|
|
192
|
+
var foundOnce = false;
|
|
193
|
+
|
|
194
|
+
if (!compositionName) compositionName = nexrender.defaultCompositionName;
|
|
195
|
+
if (!types) types = nexrender.types;
|
|
196
|
+
|
|
197
|
+
nexrender.selectCompositionsByName(compositionName, function(comp) {
|
|
198
|
+
var layer = comp.layer(index)
|
|
199
|
+
if (layer) {
|
|
200
|
+
callback(layer, index);
|
|
201
|
+
foundOnce = true;
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
if (!foundOnce && !continueOnMissing) {
|
|
206
|
+
throw new Error("nexrender: Couldn't find any layers by provided index (" + index + ") inside a composition: " + compositionName);
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/* ensure that eval only gets a minimal variable scope */
|
|
211
|
+
nexrender.evaluate = function (layer, expression) {
|
|
212
|
+
return eval(expression);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
nexrender.changeValueForKeypath = function (layer, keys, val) {
|
|
216
|
+
function change(o, keys, val) {
|
|
217
|
+
if (keys.length == 0) {
|
|
218
|
+
val.changed = false;
|
|
219
|
+
return val;
|
|
220
|
+
} else {
|
|
221
|
+
var key = keys[0];
|
|
222
|
+
if ("property" in o && o.property(key)) {
|
|
223
|
+
var prop = o.property(key)
|
|
224
|
+
if ("value" in prop) {
|
|
225
|
+
var pval = prop.value;
|
|
226
|
+
var v = change(pval, keys.slice(1), val)
|
|
227
|
+
if ("value" in v) {
|
|
228
|
+
prop.setValue(v.value)
|
|
229
|
+
} else {
|
|
230
|
+
prop.expression = v.expression
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
change(prop, keys.slice(1), val)
|
|
234
|
+
}
|
|
235
|
+
return { "value": o, "changed": true };
|
|
236
|
+
} else if (key in o) {
|
|
237
|
+
var v = change(o[key], keys.slice(1), val)
|
|
238
|
+
if (!v.changed) {
|
|
239
|
+
if ("value" in v) {
|
|
240
|
+
o[key] = v.value;
|
|
241
|
+
} else {
|
|
242
|
+
o[key] = nexrender.evaluate(layer, v.expression)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return { "value": o, "changed": true };
|
|
246
|
+
} else {
|
|
247
|
+
throw new Error("nexrender: Can't find a property sequence " + keys.join('.') + " for key: " + key + "within layer: " + layer.name);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
change(layer, keys, val);
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
/* end of nexrender script */
|
|
256
|
+
/* start of custom user script */
|
|
257
|
+
|
|
258
|
+
(function() {
|
|
259
|
+
nexrender.selectLayersByName(null, 'test', function(layer) {
|
|
260
|
+
nexrender.replaceFootage(layer, '/Users/inlife/Projects/01-nexrender/nexrender-core/packages/nexrender-core/test/workpath/svBjjvo3KlgodQHqNFtPg/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==.png', false, false)
|
|
261
|
+
}, null, undefined);
|
|
262
|
+
})();
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
/* end of custom user script */
|
|
266
|
+
},{}]},{},[1]);
|