isomorfeus-asset-manager 0.14.19 → 0.14.22

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: 5c7df0d3122b5bfff71c027bed005e9878e0bb64c6ddd1300e6256efb544ddf1
4
- data.tar.gz: 2aa0e3f088152054b47bec1b9886ed93a843774735a2e7b26d67edda01cf10a8
3
+ metadata.gz: e208b674f5b5ed724db1be5c74054c92d4b2468faea3a30267f528f36c1bb9ce
4
+ data.tar.gz: 03201b0049a608178c9a7d550749556de94ad9e9382eca635f18694ed5debd51
5
5
  SHA512:
6
- metadata.gz: 07f69556f092f6d1a8b74a8003cf4564f445fc0938bbfcf2edb68df0d43eec0c298c670284e213c059ef0ec79cca536048a8f55f22a6b543080ab5daea28f93d
7
- data.tar.gz: 6c1050f997977b5a5351fe3edc94b0c175540f565e62b187e3e3a1d31f616564d1dda5c1fa26759e36c5fa452c68042d032306475d051b4500f461cd22264467
6
+ metadata.gz: ff78d031bde9dc60794d00abd392449f6acee64845d9ba5270749dcea6fbe89c680da79c5a46975db1ff16f6c036b525f330c1fd211fc0462f842cf29cdc102c
7
+ data.tar.gz: 2088239fe557d25847360d8e5348d0052f72176384bd22492e1222569286a9c196f53284dd895c9ce46fdc93bc13c0faf045aa9bd7d72db4637c45d0a10c66d0
@@ -94,6 +94,11 @@ module Isomorfeus
94
94
  catch { console.log('Isomorfeus Asset Manager could not update locale ', update.locale) }
95
95
  return;
96
96
  }
97
+ if (typeof update.reload !== 'undefined') {
98
+ console.log('Isomorfeus Asset Manager reloading page, updating javascript import ', update.reload);
99
+ setTimeout(function() { window.location.reload(true); }, 500);
100
+ return;
101
+ }
97
102
  let start_index = 'Opal.modules[\\"'.length;
98
103
  let end_index = update.javascript.indexOf('"', start_index);
99
104
  let opal_module_name = update.javascript.substr(start_index, end_index - start_index);
@@ -78,7 +78,7 @@ module Isomorfeus
78
78
 
79
79
  self.hmr_listener = nil
80
80
  self.asset_manager_hmr_channel = :isomorfeus_asset_manager_module_updates
81
- self.asset_manager_hmr_dirs = %w[channels components data locales operations policies]
81
+ self.asset_manager_hmr_dirs = %w[channels components data imports locales mail_components operations policies server]
82
82
  self.hmr_websocket_path = '/_asset_manager_hmr_websocket'
83
83
  self.assets_path = '/assets'
84
84
  self.assets = {
@@ -49,7 +49,7 @@ module Isomorfeus
49
49
  def generate_entry(asset_name)
50
50
  js = ''
51
51
  js << "#{@js_imports.map(&:to_s).join("\n")}"
52
- js << "#{@ruby_imports.map { |i| i.to_s(asset_name) }.join("\n")}"
52
+ js << "#{@ruby_imports.map { |i| i.to_s(asset_name) }.join('')}"
53
53
  end
54
54
  end
55
55
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  class AssetManager
3
- VERSION = '0.14.19'
3
+ VERSION = '0.14.22'
4
4
  end
5
5
  end
@@ -78,22 +78,10 @@ module Isomorfeus
78
78
  { javascript: compiler.compile }
79
79
  end
80
80
 
81
- def print_message(m, level)
82
- l = m['location']
83
- STDERR.puts "#{l['file']}:#{l['line']}:#{l['column']}: #{level}: #{m['text']}"
84
- STDERR.puts " #{l['line']} | #{l['lineText']}\n\n"
85
- end
86
81
 
87
82
  def handle_errors(asset_key, result)
88
- unless result['errors'].empty?
89
- result['errors'].each do |e|
90
- print_message(e, 'error')
91
- unless e['notes'].empty?
92
- e['notes'].each do |n|
93
- print_message(n, 'note')
94
- end
95
- end
96
- end
83
+ result = result['result']
84
+ if result && !(result['errors'].nil? || result['errors'].empty?)
97
85
  raise "Asset Manager: error bundling '#{asset_key}'"
98
86
  end
99
87
  end
@@ -137,6 +125,9 @@ module Isomorfeus
137
125
  elsif file.end_with?('.yml') || file.end_with?('.mo') || file.end_with?('.po')
138
126
  Isomorfeus.server_requires_reload!
139
127
  update_json = Oj.dump({ locale: file }, mode: :strict)
128
+ elsif file.end_with?('.js')
129
+ Isomorfeus.assets.each_value { |asset| asset.unbundle! }
130
+ update_json = Oj.dump({ reload: file }, mode: :strict)
140
131
  else
141
132
  update_json = Oj.dump({ error: "Don't know how to update #{file}!" }, mode: :strict)
142
133
  end
@@ -177,7 +168,7 @@ module Isomorfeus
177
168
  target: '#{asset.browser? ? 'es6' : 'node16' }',
178
169
  write: true
179
170
  })
180
- .then((result) => { global.res_meta = result.metafile; return result; }, (reason) => { return { result: { errors: [{text: reson}]}}; })
171
+ .then((result) => { global.res_meta = result.metafile; return result; }, (reason) => { return { result: { errors: [{text: reason}]}}; })
181
172
  .catch((error) => { return { result: { errors: [{text: error.message}]}}; });
182
173
  JAVASCRIPT
183
174
  if analyze
@@ -1,18 +1,18 @@
1
- {
2
- "name": "isomorfeus-asset-manager",
3
- "lockfileVersion": 2,
4
- "requires": true,
5
- "packages": {
6
- "node_modules/esbuild-wasm": {
7
- "version": "0.14.23",
8
- "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.14.23.tgz",
9
- "integrity": "sha512-w1qhGLvUaPXiigGWIEGcnMmN/FxQ6VDLnHQIOpf29Qh9z6x4qe4gmsQyUbFBW6UsWsw/E8OJDE0XRtiV/0siYQ==",
10
- "bin": {
11
- "esbuild": "bin/esbuild"
12
- },
13
- "engines": {
14
- "node": ">=12"
15
- }
16
- }
17
- }
18
- }
1
+ {
2
+ "name": "isomorfeus-asset-manager",
3
+ "lockfileVersion": 2,
4
+ "requires": true,
5
+ "packages": {
6
+ "node_modules/esbuild-wasm": {
7
+ "version": "0.14.36",
8
+ "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.14.36.tgz",
9
+ "integrity": "sha512-tDMs2l397fd/pwLoIKb4uYfQayM5hMfUwVvCmzbFEU+zXedj15/Z/A8iD87cWHN1VD66REdgcGMt1BO6C7RnLw==",
10
+ "bin": {
11
+ "esbuild": "bin/esbuild"
12
+ },
13
+ "engines": {
14
+ "node": ">=12"
15
+ }
16
+ }
17
+ }
18
+ }
@@ -2,17 +2,18 @@
2
2
 
3
3
  // Forward to the automatically-generated WebAssembly loader from the Go compiler
4
4
 
5
+ const module_ = require('module');
5
6
  const crypto = require('crypto');
6
7
  const path = require('path');
7
8
  const zlib = require('zlib');
8
9
  const fs = require('fs');
9
10
  const os = require('os');
10
11
 
11
- const wasm_exec = path.join(__dirname, '..', 'wasm_exec.js');
12
+ const wasm_exec_node = path.join(__dirname, '..', 'wasm_exec_node.js');
12
13
  const esbuild_wasm = path.join(__dirname, '..', 'esbuild.wasm');
13
14
 
14
- const code = fs.readFileSync(wasm_exec, 'utf8');
15
- const wrapper = new Function('require', 'module', 'process', 'WebAssembly', code);
15
+ const code = fs.readFileSync(wasm_exec_node, 'utf8');
16
+ const wrapper = new Function('require', 'WebAssembly', code);
16
17
 
17
18
  function instantiate(bytes, importObject) {
18
19
  // Using this API causes "./esbuild --version" to run around 1 second faster
@@ -80,6 +81,37 @@ fs.read = function () {
80
81
  return read.apply(this, arguments);
81
82
  };
82
83
 
84
+ // Hack around a Unicode bug in node: https://github.com/nodejs/node/issues/24550.
85
+ // See this for the matching Go issue: https://github.com/golang/go/issues/43917.
86
+ const write = fs.write;
87
+ fs.write = function (fd, buf, offset, length, position, callback) {
88
+ if (offset === 0 && length === buf.length && position === null) {
89
+ if (fd === process.stdout.fd) {
90
+ try {
91
+ process.stdout.write(buf, err => err ? callback(err, 0, null) : callback(null, length, buf));
92
+ } catch (err) {
93
+ callback(err, 0, null);
94
+ }
95
+ return;
96
+ }
97
+ if (fd === process.stderr.fd) {
98
+ try {
99
+ process.stderr.write(buf, err => err ? callback(err, 0, null) : callback(null, length, buf));
100
+ } catch (err) {
101
+ callback(err, 0, null);
102
+ }
103
+ return;
104
+ }
105
+ }
106
+ return write.apply(this, arguments);
107
+ };
108
+ const writeSync = fs.writeSync;
109
+ fs.writeSync = function (fd, buf) {
110
+ if (fd === process.stdout.fd) return process.stdout.write(buf), buf.length;
111
+ if (fd === process.stderr.fd) return process.stderr.write(buf), buf.length;
112
+ return writeSync.apply(this, arguments);
113
+ };
114
+
83
115
  // WASM code generated with Go 1.17.2+ will crash when run in a situation with
84
116
  // many environment variables: https://github.com/golang/go/issues/49011. An
85
117
  // example of this situation is running a Go-compiled WASM executable in GitHub
@@ -97,5 +129,5 @@ for (let key in process.env) {
97
129
  }
98
130
  }
99
131
 
100
- const argv = ['node', wasm_exec, esbuild_wasm].concat(process.argv.slice(2));
101
- wrapper(require, require.main, Object.assign(Object.create(process), { argv }), Object.assign(Object.create(WebAssembly), { instantiate }));
132
+ process.argv.splice(2, 0, esbuild_wasm);
133
+ wrapper(module_.createRequire(wasm_exec_node), Object.assign(Object.create(WebAssembly), { instantiate }));
Binary file
@@ -7,7 +7,7 @@ export type Drop = 'console' | 'debugger';
7
7
 
8
8
  interface CommonOptions {
9
9
  /** Documentation: https://esbuild.github.io/api/#sourcemap */
10
- sourcemap?: boolean | 'inline' | 'external' | 'both';
10
+ sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
11
11
  /** Documentation: https://esbuild.github.io/api/#legal-comments */
12
12
  legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external';
13
13
  /** Documentation: https://esbuild.github.io/api/#source-root */
@@ -27,6 +27,8 @@ interface CommonOptions {
27
27
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
28
28
  reserveProps?: RegExp;
29
29
  /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
+ mangleQuoted?: boolean;
31
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
32
  mangleCache?: Record<string, string | false>;
31
33
  /** Documentation: https://esbuild.github.io/api/#drop */
32
34
  drop?: Drop[];
@@ -569,6 +571,16 @@ export interface InitializeOptions {
569
571
  */
570
572
  wasmURL?: string
571
573
 
574
+ /**
575
+ * The result of calling "new WebAssembly.Module(buffer)" where "buffer"
576
+ * is a typed array or ArrayBuffer containing the binary code of the
577
+ * "esbuild.wasm" file.
578
+ *
579
+ * You can use this as an alternative to "wasmURL" for environments where it's
580
+ * not possible to download the WebAssembly module.
581
+ */
582
+ wasmModule?: WebAssembly.Module
583
+
572
584
  /**
573
585
  * By default esbuild runs the WebAssembly-based browser API in a web worker
574
586
  * to avoid blocking the UI thread. This can be disabled by setting "worker"