isomorfeus-speednode 0.4.1 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1bb65853d666ae62943ed28b887dc6792c83c34bd7ed090d7bc817a42e40c63e
4
- data.tar.gz: '0227178ecf8760e07f32043beba064258da9efa6baa221c96b0437ee12a6fc80'
3
+ metadata.gz: 87a39ac56870791f30d5da2cd2421132b54360e732596b487a674fd77985bfb4
4
+ data.tar.gz: e9f56a2e8f8596e7757da194b70fe299ec63566472da5e81188a997b6fb54558
5
5
  SHA512:
6
- metadata.gz: ee26a18eb0e0209f543ce01cf240824edd3d00c8590a57c72a0422680c48127318a4111f7417f424b48ae8ffbc72b43c3bac7c03da8ee62baa265a49880471e8
7
- data.tar.gz: a9da737b51f2b115bac2c218d2abc0618b443daa2cc2cd380991a30b4b4a998cb6c2497356d30279f04e717c86cf61a557173506b19859b711ca895a10880d75
6
+ metadata.gz: d5710791bcc21e6694223d430ef943d526819a7159442003285ab0e12c07cf168856394a2eaf825edd82aca5d96b3da609322694237d9cbb069e4a25d97ddf63
7
+ data.tar.gz: 1dac21aab4f330ba546ae5389facd15858120109ae7996b955108c39bbb004f72ca612c63c8fd78b485c4a723fd9c03ddc6bdeddaf87766f92b213090c51e37a
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
- # isomorfeus-speednode
1
+ <h1 align="center">
2
+ <img src="https://github.com/isomorfeus/isomorfeus-speednode/blob/master/Logo.png?raw=true" align="center" width="234" height="127"/><br/>
3
+ Isomorfeus Speednode<br/>
4
+ </h1>
2
5
 
3
6
  A fast runtime for execjs using node js. Works on Linux, BSDs, MacOS and Windows.
4
7
  Inspired by [execjs-fastnode](https://github.com/jhawthorn/execjs-fastnode).
5
8
 
6
9
  ### Community and Support
7
- At the [Isomorfeus Framework Project](http://isomorfeus.com)
8
-
9
- ### Tested
10
- [TravisCI](https://travis-ci.org): [![Build Status](https://travis-ci.org/isomorfeus/isomorfeus-speednode.svg?branch=master)](https://travis-ci.org/isomorfeus/isomorfeus-speednode)
10
+ At the [Isomorfeus Framework Project](http://isomorfeus.com)
11
11
 
12
12
  ### Installation
13
13
 
@@ -40,8 +40,8 @@ Example for a compatible context:
40
40
  compat_context = ExecJS.compile('Test = "test"')
41
41
  compat_context.eval('1+1')
42
42
  ```
43
- #### Permissive
44
- A permissive context can be created with `ExecJS.permissive_compile` or code can be executed within a permissive context by using
43
+ #### Permissive
44
+ A permissive context can be created with `ExecJS.permissive_compile` or code can be executed within a permissive context by using
45
45
  `ExecJS.permissive_eval` or `ExecJS.permissive_exec`.
46
46
  Example for a permissive context:
47
47
  ```ruby
@@ -63,7 +63,7 @@ context.eval <<~JAVASCRIPT
63
63
  return new Promise(function (resolve, reject) { resolve(val); });
64
64
  }
65
65
  JAVASCRIPT
66
-
66
+
67
67
  context.await("foo('test')") # => 'test'
68
68
  ```
69
69
 
@@ -135,7 +135,7 @@ function attachFunctionSource(responder_path, context, func) {
135
135
  if (!global.__responder_socket) {\n\
136
136
  return new Promise(function(resolve, reject) {\n\
137
137
  setTimeout(function(){\n\
138
- if (os.platform().indexOf('win') > -1) {\n\
138
+ if (os.platform().indexOf('win') == 0) {\n\
139
139
  let socket = net.connect(responder_path);\n\
140
140
  socket.on('connect', function(){\n\
141
141
  global.__responder_socket = true;\n\
@@ -160,9 +160,9 @@ function attachFunctionSource(responder_path, context, func) {
160
160
  socket.on('error', function (err) {\n\
161
161
  if (err.syscall === 'connect') {\n\
162
162
  // ignore, close will handle\n\
163
- } else if (os.platform().indexOf('win') > -1 && err.message.includes('read EPIPE')) {\n\
163
+ } else if ((os.platform().indexOf('win') == 0) && err.message.includes('read EPIPE')) {\n\
164
164
  // ignore, close will handle\n\
165
- } else if (os.platform().indexOf('win') > -1 && err.message.includes('write EPIPE')) {\n\
165
+ } else if ((os.platform().indexOf('win') == 0) && err.message.includes('write EPIPE')) {\n\
166
166
  // ignore, close will handle\n\
167
167
  } else { reject(err); }\n\
168
168
  });\n\
@@ -200,7 +200,8 @@ function createCompatibleContext(uuid, options) {
200
200
  }
201
201
 
202
202
  function createPermissiveContext(uuid, options) {
203
- let c = vm.createContext({ global: { __responder_socket: false }, process: { release: { name: "node" }, env: process.env }, Buffer, clearTimeout, fs, net, os, require, setTimeout });
203
+ let c = vm.createContext({ __responder_socket: false, process: { release: { name: "node" }, env: process.env }, Buffer, clearTimeout, fs, net, os, require, setTimeout });
204
+ vm.runInContext('global = globalThis;', c);
204
205
  contexts[uuid] = { context: c, options: options };
205
206
  return c;
206
207
  }
@@ -223,7 +224,7 @@ function getContextOptions(uuid) {
223
224
  if (contexts[uuid].options.timeout) {
224
225
  options.timeout = contexts[uuid].options.timeout;
225
226
  }
226
- return options;
227
+ return options;
227
228
  }
228
229
 
229
230
  function massageStackTrace(stack) {
@@ -241,7 +242,7 @@ let commands = {
241
242
  attach: function(input) {
242
243
  let context = getContext(input.context);
243
244
  let responder_path;
244
- if (os.platform().indexOf('win') > -1) { responder_path = '\\\\\\\\.\\\\pipe\\\\' + socket_path + '_responder'; }
245
+ if (os.platform().indexOf('win') == 0) { responder_path = '\\\\\\\\.\\\\pipe\\\\' + socket_path + '_responder'; }
245
246
  else { responder_path = socket_path + '_responder' }
246
247
  let result = vm.runInContext(attachFunctionSource(responder_path, input.context, input.func), context, { filename: "(execjs)", displayErrors: true });
247
248
  return formatResult(result);
@@ -285,23 +286,23 @@ let server = net.createServer(function(s) {
285
286
  s.on('data', function (data) {
286
287
  received_data.push(data);
287
288
  if (data[data.length - 1] !== 4) { return; }
288
-
289
+
289
290
  let request = received_data.join('').toString('utf8');
290
291
  request = request.substr(0, request.length - 1);
291
292
  received_data = [];
292
-
293
+
293
294
  let input, result;
294
295
  let outputJSON = '';
295
296
 
296
297
  try { input = JSON.parse(request); }
297
- catch(err) {
298
+ catch(err) {
298
299
  outputJSON = JSON.stringify(['err', ['', err].join(''), err.stack]);
299
300
  s.write([outputJSON, "\x04"].join(''));
300
301
  return;
301
302
  }
302
303
 
303
- try { result = commands[input.cmd].apply(null, input.args); }
304
- catch (err) {
304
+ try { result = commands[input.cmd].apply(null, input.args); }
305
+ catch (err) {
305
306
  outputJSON = JSON.stringify(['err', ['', err].join(''), massageStackTrace(err.stack)]);
306
307
  s.write([outputJSON, "\x04"].join(''));
307
308
  return;
@@ -322,5 +323,5 @@ let server = net.createServer(function(s) {
322
323
  });
323
324
  });
324
325
 
325
- if (os.platform().indexOf('win') > -1) { server.listen('\\\\.\\pipe\\' + socket_path); }
326
+ if (os.platform().indexOf('win') == 0) { server.listen('\\\\.\\pipe\\' + socket_path); }
326
327
  else { server.listen(socket_path); }
@@ -56,7 +56,7 @@ module Isomorfeus
56
56
  end
57
57
 
58
58
  def self.finalize(socket, socket_dir, socket_path, pid)
59
- proc do
59
+ proc do
60
60
  Isomorfeus::Speednode::Runtime.responders[socket_path].kill if Isomorfeus::Speednode::Runtime.responders[socket_path]
61
61
  exit_node(socket, socket_dir, socket_path, pid)
62
62
  end
@@ -97,7 +97,7 @@ module Isomorfeus
97
97
 
98
98
  def attach(context, func)
99
99
  create_responder(context) unless responder
100
- command("attach", {'context' => context, 'func' => func })
100
+ command("attach", {'context' => context, 'func' => func })
101
101
  end
102
102
 
103
103
  def delete_context(context)
@@ -125,14 +125,18 @@ module Isomorfeus
125
125
  @socket_dir = Dir.mktmpdir("isomorfeus-speednode-")
126
126
  @socket_path = File.join(@socket_dir, "socket")
127
127
  end
128
- @pid = Process.spawn({"SOCKET_PATH" => @socket_path}, @options[:binary], @options[:source_maps], @options[:runner_path])
128
+ @pid = if @options.key?(:source_maps)
129
+ Process.spawn({"SOCKET_PATH" => @socket_path}, @options[:binary], @options[:source_maps], @options[:runner_path])
130
+ else
131
+ Process.spawn({"SOCKET_PATH" => @socket_path}, @options[:binary], @options[:runner_path])
132
+ end
129
133
 
130
- retries = 20
134
+ retries = 100
131
135
 
132
136
  if ExecJS.windows?
133
137
  timeout_or_connected = false
134
138
  begin
135
- retries -= 1
139
+ retries -= 1
136
140
  begin
137
141
  @socket = Win32::Pipe::Client.new(@socket_path, Win32::Pipe::ACCESS_DUPLEX)
138
142
  rescue
@@ -22,11 +22,11 @@ module Isomorfeus
22
22
  @encoding = options[:encoding]
23
23
  @deprecated = !!options[:deprecated]
24
24
 
25
- @vm = VM.new(
26
- binary: @binary,
27
- source_maps: '--enable-source-maps',
28
- runner_path: @runner_path
29
- )
25
+ @vm = if Gem::Platform.local.cpu.start_with?('arm')
26
+ VM.new(binary: @binary, runner_path: @runner_path)
27
+ else
28
+ VM.new(binary: @binary, source_maps: '--enable-source-maps', runner_path: @runner_path)
29
+ end
30
30
 
31
31
  @popen_options = {}
32
32
  @popen_options[:external_encoding] = @encoding if @encoding
@@ -1,5 +1,5 @@
1
- module Isomorfeus
2
- module Speednode
3
- VERSION = '0.4.1'
4
- end
5
- end
1
+ module Isomorfeus
2
+ module Speednode
3
+ VERSION = '0.4.5'
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-speednode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-05 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: execjs
@@ -28,28 +28,28 @@ dependencies:
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 3.13.3
33
+ version: 3.13.9
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 3.13.3
40
+ version: 3.13.9
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: win32-pipe
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 0.4.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.4.0
55
55
  - !ruby/object:Gem::Dependency
@@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
150
  - !ruby/object:Gem::Version
151
151
  version: '0'
152
152
  requirements: []
153
- rubygems_version: 3.2.15
153
+ rubygems_version: 3.2.22
154
154
  signing_key:
155
155
  specification_version: 4
156
156
  summary: A fast ExecJS runtime based on nodejs, tuned for Isomorfeus.