@nexrender/core 1.35.0 → 1.37.4

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 CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@nexrender/core",
3
- "version": "1.35.0",
3
+ "version": "1.37.4",
4
4
  "main": "src/index.js",
5
5
  "author": "Inlife",
6
6
  "scripts": {
7
7
  "pkg-prelink": "node ../../misc/prelink.js"
8
8
  },
9
9
  "dependencies": {
10
- "@nexrender/types": "^1.27.0",
10
+ "@nexrender/types": "^1.37.4",
11
11
  "data-uri-to-buffer": "^3.0.0",
12
12
  "file-uri-to-path": "^2.0.0",
13
13
  "is-wsl": "^2.2.0",
14
14
  "match-all": "^1.2.5",
15
15
  "mime-types": "^2.1.29",
16
16
  "mkdirp": "^1.0.4",
17
- "node-fetch": "^2.6.1",
17
+ "node-fetch": "^3.1.1",
18
18
  "requireg": "^0.2.1",
19
19
  "rimraf": "^3.0.2"
20
20
  },
@@ -29,5 +29,5 @@
29
29
  "publishConfig": {
30
30
  "access": "public"
31
31
  },
32
- "gitHead": "733da5702713cda3df5197b80f35eb4fbd74bd45"
32
+ "gitHead": "5c7ca4176893c4f2c300fd2e950400cb8f25de5a"
33
33
  }
@@ -33,8 +33,8 @@ module.exports = (settings) => {
33
33
  if (data.indexOf('nexrender-patch') !== -1) {
34
34
  settings.logger.log('command line patch already is in place')
35
35
 
36
- const patchedMatch = patched.match(/nexrender-patch-v([0-9\.]+)/)
37
- const existingMatch = data.match(/nexrender-patch-v([0-9\.]+)/)
36
+ const patchedMatch = patched.match(/nexrender-patch-v([0-9.]+)/)
37
+ const existingMatch = data.match(/nexrender-patch-v([0-9.]+)/)
38
38
 
39
39
  if (patchedMatch[1] !== existingMatch[1]) {
40
40
  try {
package/src/index.js CHANGED
@@ -48,7 +48,7 @@ const init = (settings) => {
48
48
  const binaryUser = settings.binary && fs.existsSync(settings.binary) ? settings.binary : null;
49
49
 
50
50
  if (!binaryUser && !binaryAuto) {
51
- throw new Error('you should provide a proper path to After Effects\' \"aerender\" binary')
51
+ throw new Error('you should provide a proper path to After Effects\' "aerender" binary')
52
52
  }
53
53
 
54
54
  if (binaryAuto && !binaryUser) {
@@ -1,5 +1,3 @@
1
- const fs = require('fs')
2
- const path = require('path')
3
1
  const rimraf = require('rimraf')
4
2
 
5
3
  /**
@@ -11,7 +9,7 @@ module.exports = function(job, settings) {
11
9
  return Promise.resolve(job)
12
10
  }
13
11
 
14
- return new Promise((resolve, reject) => {
12
+ return new Promise((resolve) => {
15
13
  settings.logger.log(`[${job.uid}] cleaning up...`);
16
14
 
17
15
  rimraf(job.workpath, {glob: false}, (err) => {
@@ -13,8 +13,9 @@ const requireg = require('requireg')
13
13
  const download = (job, settings, asset) => {
14
14
  if (asset.type == 'data') return Promise.resolve();
15
15
 
16
+ // eslint-disable-next-line
16
17
  const uri = global.URL ? new URL(asset.src) : url.parse(asset.src)
17
- const protocol = uri.protocol.replace(/\:$/, '');
18
+ const protocol = uri.protocol.replace(/:$/, '');
18
19
  let destName = '';
19
20
 
20
21
  /* if asset doesnt have a file name, make up a random one */
@@ -23,7 +24,8 @@ const download = (job, settings, asset) => {
23
24
  } else {
24
25
  destName = path.basename(asset.src)
25
26
  destName = destName.indexOf('?') !== -1 ? destName.slice(0, destName.indexOf('?')) : destName;
26
- /* ^ remove possible query search string params ^ */;
27
+ /* ^ remove possible query search string params ^ */
28
+ destName = decodeURI(destName) /* < remove/decode any special URI symbols within filename */
27
29
 
28
30
  /* prevent same name file collisions */
29
31
  if (fs.existsSync(path.join(job.workpath, destName))) {
@@ -61,7 +63,6 @@ const download = (job, settings, asset) => {
61
63
  reject(err)
62
64
  }
63
65
  });
64
- break;
65
66
 
66
67
  case 'http':
67
68
  case 'https':
@@ -77,14 +78,13 @@ const download = (job, settings, asset) => {
77
78
 
78
79
  asset.extension = fileExt
79
80
  const destHasExtension = path.extname(asset.dest) ? true : false
80
- //don't do this if asset.dest already has extension else it gives you example.jpg.jpg like file in case of assets and aep/aepx file
81
+ //don't do this if asset.dest already has extension else it gives you example.jpg.jpg like file in case of assets and aep/aepx file
81
82
  if (asset.extension && !destHasExtension) {
82
83
  asset.dest += `.${fileExt}`
83
84
  }
84
85
  }
85
86
 
86
87
  const stream = fs.createWriteStream(asset.dest)
87
- let timer
88
88
 
89
89
  return new Promise((resolve, reject) => {
90
90
  const errorHandler = (error) => {
@@ -100,7 +100,6 @@ const download = (job, settings, asset) => {
100
100
  .on('finish', resolve)
101
101
  })
102
102
  });
103
- break;
104
103
 
105
104
  case 'file':
106
105
  const filepath = uri2path(expandEnvironmentVariables(asset.src))
@@ -125,7 +124,6 @@ const download = (job, settings, asset) => {
125
124
  wr.end()
126
125
  throw error
127
126
  })
128
- break;
129
127
 
130
128
  /* custom/external handlers */
131
129
  default:
@@ -134,13 +132,12 @@ const download = (job, settings, asset) => {
134
132
  return requireg('@nexrender/provider-' + protocol).download(job, settings, asset.src, asset.dest, asset.params || {});
135
133
  } catch (e) {
136
134
  if (e.message.indexOf('Could not require module') !== -1) {
137
- return Promise.reject(new Error(`Couldn\'t find module @nexrender/provider-${protocol}, Unknown protocol provided.`))
135
+ return Promise.reject(new Error(`Couldn't find module @nexrender/provider-${protocol}, Unknown protocol provided.`))
138
136
  }
139
137
 
140
138
  throw e;
141
139
  }
142
140
 
143
- break;
144
141
  }
145
142
  }
146
143
 
@@ -156,5 +153,5 @@ module.exports = function(job, settings) {
156
153
  job.assets.map(asset => download(job, settings, asset))
157
154
  )
158
155
 
159
- return Promise.all(promises).then(_ => job);
156
+ return Promise.all(promises).then(() => job);
160
157
  }
@@ -29,7 +29,7 @@ module.exports = (job, settings) => {
29
29
  let outputFile = expandEnvironmentVariables(job.output)
30
30
  let projectFile = expandEnvironmentVariables(job.template.dest)
31
31
 
32
- outputFileAE = checkForWSL(outputFile, settings)
32
+ const outputFileAE = checkForWSL(outputFile, settings)
33
33
  projectFile = checkForWSL(projectFile, settings)
34
34
  let jobScriptFile = checkForWSL(job.scriptfile, settings)
35
35
 
@@ -62,7 +62,7 @@ module.exports = (job, settings) => {
62
62
  }
63
63
 
64
64
  if (settings['aeParams']) {
65
- for (param of settings['aeParams']) {
65
+ for (const param of settings['aeParams']) {
66
66
  let ps = param.split(" ");
67
67
 
68
68
  if (ps.length > 0) {
@@ -8,7 +8,7 @@ const { checkForWSL } = require('../helpers/path')
8
8
  const escape = str => {
9
9
  str = JSON.stringify(str)
10
10
  str = str.substring(1, str.length-1)
11
- str = `'${str.replace(/\'/g, '\\\'')}'`
11
+ str = `'${str.replace(/'/g, '\\\'')}'`
12
12
  return str
13
13
  }
14
14
 
@@ -50,9 +50,9 @@ const wrapData = ({ property, value, expression, ...asset }) => (`(function() {
50
50
  })();\n`)
51
51
 
52
52
  // @deprecated in favor of wrapEnhancedScript (implementation below)
53
- const wrapScript = ({ dest }) => (`(function() {
54
- ${fs.readFileSync(dest, 'utf8')}
55
- })();\n`)
53
+ // const wrapScript = ({ dest }) => (`(function() {
54
+ // ${fs.readFileSync(dest, 'utf8')}
55
+ // })();\n`)
56
56
 
57
57
 
58
58
  /*
@@ -72,7 +72,8 @@ const wrapScript = ({ dest }) => (`(function() {
72
72
 
73
73
  @return string (String) The compiled script with parameter injection outside its original scope to avoid user-defined defaults collision.
74
74
  */
75
- const wrapEnhancedScript = ({ dest, src, parameters = [], keyword, defaults, ...asset }, jobID, settings) => {
75
+ const wrapEnhancedScript = ({ dest, src, parameters = [], keyword, defaults, /* ...asset */ }, jobID, settings) => {
76
+ let arg, fullMatch;
76
77
 
77
78
  function EnhancedScript (
78
79
  dest,
@@ -238,7 +239,8 @@ const wrapEnhancedScript = ({ dest, src, parameters = [], keyword, defaults, ..
238
239
  this.getLogger().log("We found a self-invoking method with arguments!");
239
240
  this.getLogger().log(JSON.stringify(methodArgs));
240
241
  const foundArgument = methodArgs.filter( argMatch => {
241
- [fullMatch, method, arg] = argMatch;
242
+ fullMatch = argMatch[0]
243
+ arg = argMatch[2]
242
244
 
243
245
  return parameter.arguments && parameter.arguments.find(o => o.key == arg);
244
246
  });
@@ -315,7 +317,7 @@ const wrapEnhancedScript = ({ dest, src, parameters = [], keyword, defaults, ..
315
317
  if (nxMatches && nxMatches.length > 0 ) {
316
318
 
317
319
  nxMatches.forEach( match => {
318
- const [fullMatch, method, keyword] = match;
320
+ const keyword = match[2];
319
321
 
320
322
  var nxMatch = {
321
323
  key: keyword.replace(/\s/g, ''),
@@ -357,7 +359,7 @@ const wrapEnhancedScript = ({ dest, src, parameters = [], keyword, defaults, ..
357
359
 
358
360
  return `
359
361
  "parameters" : [
360
- ${missingParams.map((k, i) => template(k.key)).join("\n")}
362
+ ${missingParams.map((k) => template(k.key)).join("\n")}
361
363
  ]
362
364
  `
363
365
  }
@@ -406,7 +408,7 @@ const wrapEnhancedScript = ({ dest, src, parameters = [], keyword, defaults, ..
406
408
  EnhancedScript.prototype.buildParameterConfigurator = function () {
407
409
 
408
410
  const defaultGlobalValue = this.getStringifiedDefaultValue( this.defaults.global );
409
- const defaultFnValue = this.getDefaultValue( this.defaults.function );
411
+ // const defaultFnValue = this.getDefaultValue( this.defaults.function );
410
412
  const createParameterConfigurator = () => `
411
413
  function ParameterConfigurator () {
412
414
  this.params = [];
@@ -1,5 +1,4 @@
1
1
  const os = require('os')
2
- const fs = require('fs')
3
2
  const path = require('path')
4
3
  const mkdirp = require('mkdirp')
5
4
  const assert = require('assert')
package/test/mytest.js CHANGED
@@ -1,9 +1,7 @@
1
- module.exports = (job, settings) => {
1
+ module.exports = (job, /* settings */) => {
2
2
  console.log('custom module hello world!')
3
3
  return Promise.resolve(job)
4
4
  }
5
5
 
6
- const url = require('url');
7
-
8
6
  console.log(new URL('d:/Documents/resource.txt'))
9
7
  console.log(new URL('data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D'))