isomorfeus-asset-manager 0.14.6 → 0.14.10

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a63a4b134ab1cde4ab7e130434a5c58fdf9032da7cf2f6ee02b3bbbcb520355a
4
- data.tar.gz: 41fb59ad6245a093215a9dacd87a7bcf0f57203ffbf1dcffa9a8cbf3f8bb8662
3
+ metadata.gz: dd67d5e589186012d44384e22c24ecc58f6d91ea8d5596aed46c8d6a130b9275
4
+ data.tar.gz: 8981272264e96d66ace7e1f942c3c985bf9f99d7ef0cb4da836c2ecad5f3f87f
5
5
  SHA512:
6
- metadata.gz: a2f6056029f97fd832be797d084c447b34efa4c68e503107d5995a4c8a95784cfbd23a9f5031da8e8bb196944979f8bccc4fa307cdb58cf95963eaed06da8ada
7
- data.tar.gz: 19531ac72416188808d6deacf15d46af3813cc073bf38c6beb2670d0c92fded90f2789fa3a1c1a5aa0229a992845ccff700581d5c6fe011858eceb4552da02e0
6
+ metadata.gz: db8bb45d6f08592354a67591edaf1c463dc57b3aea3d6fac6b61eb00ca4ac3eda700a20934e48b4fb90d18983af81ac5f1a5faea181aaa5f59ff2c2ce986ab86
7
+ data.tar.gz: 21ba109c1c94ec3b1a13ccf647ebb6ba92a3c2b1eeb3fa266d973b05569b5b065ffb6246997ec1cf6e94374a09979f8ac643fd36791270702ca4157cd7df848d
data/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Jan Biedermann
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Jan Biedermann
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -12,4 +12,4 @@ No need to install esbuild separately, everything bundled ready to go.
12
12
  However, if within the project the 'esbuild' npm package is installed in node_modules, that version will be used instead.
13
13
 
14
14
  ### Community and Support
15
- At the [Isomorfeus Framework Project](http://isomorfeus.com)
15
+ At the [Isomorfeus Framework Project](https://isomorfeus.com)
@@ -108,23 +108,39 @@ module Isomorfeus
108
108
  // Isomorfeus Asset Manager HMR code begin
109
109
  let ws_protocol = (window.location.protocol == 'https:') ? 'wss:' : 'ws:';
110
110
  let ws_url = ws_protocol + '//' + window.location.host + "#{Isomorfeus.assets_websocket_path}";
111
- let hmr_ws = new WebSocket(ws_url);
112
- hmr_ws.onmessage = function(event) {
113
- let update = JSON.parse(event.data);
114
- if (typeof update.error !== 'undefined') { console.error(update.error); return; }
115
- let start_index = 'Opal.modules[\\"'.length;
116
- let end_index = update.javascript.indexOf('"', start_index);
117
- let opal_module_name = update.javascript.substr(start_index, end_index - start_index);
118
- console.log('Updating ', opal_module_name);
119
- if (typeof Opal !== 'undefined' && typeof Opal.require_table !== "undefined" && Opal.require_table['corelib/module']) {
120
- try {
121
- eval(update.javascript);
122
- if (Opal.require_table[opal_module_name]) { Opal.load.call(Opal, opal_module_name); }
123
- else { Opal.require.call(Opal, opal_module_name); }
124
- Opal.Isomorfeus.$force_render();
125
- } catch (e) { console.error(e); return; }
126
- }
111
+ let hmr_ws_fun = function() {
112
+ let hmr_ws = new WebSocket(ws_url);
113
+ hmr_ws.onopen = function(event) { console.log("Isomorfeus Asset Manager HMR socket connected"); }
114
+ hmr_ws.onmessage = function(event) {
115
+ let update = JSON.parse(event.data);
116
+ if (typeof update.error !== 'undefined') { console.error(update.error); return; }
117
+ if (typeof update.locale !== 'undefined') {
118
+ console.log('Isomorfeus Asset Manager updating locale ', update.locale);
119
+ try { Opal.Isomorfeus.I18n.Init.$reload_from_server(); }
120
+ catch { console.log('Isomorfeus Asset Manager could not update locale ', update.locale) }
121
+ return;
122
+ }
123
+ let start_index = 'Opal.modules[\\"'.length;
124
+ let end_index = update.javascript.indexOf('"', start_index);
125
+ let opal_module_name = update.javascript.substr(start_index, end_index - start_index);
126
+ console.log('Isomorfeus Asset Manager updating ', opal_module_name);
127
+ if (typeof Opal !== 'undefined' && typeof Opal.require_table !== "undefined" && Opal.require_table['corelib/module']) {
128
+ try {
129
+ eval(update.javascript);
130
+ if (Opal.require_table[opal_module_name]) { Opal.load.call(Opal, opal_module_name); }
131
+ else { Opal.require.call(Opal, opal_module_name); }
132
+ Opal.Isomorfeus.$force_render();
133
+ } catch (e) { console.error(e); return; }
134
+ }
135
+ };
136
+ hmr_ws.onclose = function(event) {
137
+ setTimeout(function() {
138
+ console.log("Isomorfeus Asset Manager reconnecting HMR socket");
139
+ hmr_ws_fun();
140
+ }, 2000);
141
+ };
127
142
  }
143
+ hmr_ws_fun()
128
144
  // Isomorfeus Asset Manager HMR code end
129
145
  JAVASCRIPT
130
146
  end
@@ -66,8 +66,8 @@ module Isomorfeus
66
66
 
67
67
  self.hmr_listener = nil
68
68
  self.asset_manager_hmr_channel = :isomorfeus_asset_manager_module_updates
69
- self.asset_manager_hmr_dirs = %w[channels components data operations policies]
70
- self.assets_websocket_path = '/_assets_websocket'
69
+ self.asset_manager_hmr_dirs = %w[channels components data locales operations policies]
70
+ self.assets_websocket_path = '/_asset_manager_hmr_websocket'
71
71
  self.assets_path = '/assets'
72
72
  self.assets = {
73
73
  'web.js' => Isomorfeus::AssetManager::Asset.new(:browser),
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  class AssetManager
3
- VERSION = '0.14.6'
3
+ VERSION = '0.14.10'
4
4
  end
5
5
  end
@@ -168,11 +168,17 @@ module Isomorfeus
168
168
  am_class.last_updated = (Time.now.to_f * (10 ** 9)).to_i
169
169
  next if file.start_with?(@server_path)
170
170
  begin
171
- update = compile_ruby(file)
172
- update_json = Oj.dump(update, mode: :strict)
171
+ if file.end_with?('.rb')
172
+ update = compile_ruby(file)
173
+ update_json = Oj.dump(update, mode: :strict)
174
+ elsif file.end_with?('.yml') || file.end_with?('.mo') || file.end_with?('.po')
175
+ update_json = Oj.dump({ locale: file }, mode: :strict)
176
+ else
177
+ update_json = Oj.dump({ error: "Don't know how to update #{file}!" }, mode: :strict)
178
+ end
173
179
  Iodine.publish(Isomorfeus.asset_manager_hmr_channel, update_json)
174
180
  rescue Exception => e
175
- message = "#{e.message}\n#{e.backtrace.join("\n")}"
181
+ message = "IsomorfeusAssetManager during hot module update:\n#{e.class}\n#{e.message}\n#{e.backtrace.join("\n")}"
176
182
  STDERR.puts message
177
183
  Iodine.publish(Isomorfeus.asset_manager_hmr_channel, Oj.dump({ error: message }, mode: :strict))
178
184
  end
@@ -191,13 +197,14 @@ module Isomorfeus
191
197
  resolve_paths << 'node_modules'
192
198
  resolve_paths.uniq!
193
199
 
194
- result = @context.exec <<~JAVASCRIPT
195
- let res = esbuild.buildSync({
200
+ result = @context.await <<~JAVASCRIPT
201
+ esbuild.build({
196
202
  entryPoints: [path.resolve(global.imports_path, '#{asset_key}')],
197
203
  bundle: true,
198
204
  color: false,
199
205
  format: '#{asset.target == :node ? 'cjs' : 'iife'}',
200
206
  legalComments: 'linked',
207
+ loader: { '.svg': 'text' },
201
208
  metafile: true,
202
209
  minify: #{Isomorfeus.production? ? 'true' : 'false'},
203
210
  nodePaths: #{resolve_paths},
@@ -208,9 +215,7 @@ module Isomorfeus
208
215
  splitting: false,
209
216
  target: 'es6',
210
217
  write: true
211
- });
212
- global.res_meta = res.metafile;
213
- return res;
218
+ }).then((result) => { global.res_meta = result.metafile; return result; });
214
219
  JAVASCRIPT
215
220
  if analyze
216
221
  analysis = @context.await <<~JAVASCRIPT
@@ -4,14 +4,14 @@
4
4
  "requires": true,
5
5
  "packages": {
6
6
  "node_modules/esbuild-wasm": {
7
- "version": "0.14.13",
8
- "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.14.13.tgz",
9
- "integrity": "sha512-niRkHnjbCSscizzSCtYfc0shAjrK4OXT9COaBdUFuWebx5+2gjXU4YbZohVGLvEf89hh6/U3z+JGMTAF4PajZg==",
7
+ "version": "0.14.21",
8
+ "resolved": "https://registry.npmjs.org/esbuild-wasm/-/esbuild-wasm-0.14.21.tgz",
9
+ "integrity": "sha512-sPMyljBiKxXjW1wLd5dQnrUJR1PAt8ybSidXoZWJnMuB1mpdLju57LtstDWWkCgcaE+TGJJ6NqP/OtGyeDdEAA==",
10
10
  "bin": {
11
11
  "esbuild": "bin/esbuild"
12
12
  },
13
13
  "engines": {
14
- "node": ">=8"
14
+ "node": ">=12"
15
15
  }
16
16
  }
17
17
  }
Binary file
@@ -22,6 +22,13 @@ interface CommonOptions {
22
22
  /** Documentation: https://esbuild.github.io/api/#target */
23
23
  target?: string | string[];
24
24
 
25
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
26
+ mangleProps?: RegExp;
27
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
28
+ reserveProps?: RegExp;
29
+ /** Documentation: https://esbuild.github.io/api/#mangle-props */
30
+ mangleCache?: Record<string, string | false>;
31
+ /** Documentation: https://esbuild.github.io/api/#drop */
25
32
  drop?: Drop[];
26
33
  /** Documentation: https://esbuild.github.io/api/#minify */
27
34
  minify?: boolean;
@@ -195,6 +202,8 @@ export interface BuildResult {
195
202
  stop?: () => void;
196
203
  /** Only when "metafile: true" */
197
204
  metafile?: Metafile;
205
+ /** Only when "mangleCache" is present */
206
+ mangleCache?: Record<string, string | false>;
198
207
  }
199
208
 
200
209
  export interface BuildFailure extends Error {
@@ -248,6 +257,8 @@ export interface TransformResult {
248
257
  code: string;
249
258
  map: string;
250
259
  warnings: Message[];
260
+ /** Only when "mangleCache" is present */
261
+ mangleCache?: Record<string, string | false>;
251
262
  }
252
263
 
253
264
  export interface TransformFailure extends Error {
@@ -251,6 +251,21 @@ function validateInitializeOptions(options) {
251
251
  worker
252
252
  };
253
253
  }
254
+ function validateMangleCache(mangleCache) {
255
+ let validated;
256
+ if (mangleCache !== void 0) {
257
+ validated = /* @__PURE__ */ Object.create(null);
258
+ for (let key of Object.keys(mangleCache)) {
259
+ let value = mangleCache[key];
260
+ if (typeof value === "string" || value === false) {
261
+ validated[key] = value;
262
+ } else {
263
+ throw new Error(`Expected ${JSON.stringify(key)} in mangle cache to map to either a string or false`);
264
+ }
265
+ }
266
+ }
267
+ return validated;
268
+ }
254
269
  function pushLogFlags(flags, options, keys, isTTY, logLevelDefault) {
255
270
  let color = getFlag(options, keys, "color", mustBeBoolean);
256
271
  let logLevel = getFlag(options, keys, "logLevel", mustBeString);
@@ -269,6 +284,8 @@ function pushCommonFlags(flags, options, keys) {
269
284
  let target = getFlag(options, keys, "target", mustBeStringOrArray);
270
285
  let format = getFlag(options, keys, "format", mustBeString);
271
286
  let globalName = getFlag(options, keys, "globalName", mustBeString);
287
+ let mangleProps = getFlag(options, keys, "mangleProps", mustBeRegExp);
288
+ let reserveProps = getFlag(options, keys, "reserveProps", mustBeRegExp);
272
289
  let minify = getFlag(options, keys, "minify", mustBeBoolean);
273
290
  let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
274
291
  let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
@@ -316,6 +333,10 @@ function pushCommonFlags(flags, options, keys) {
316
333
  if (drop)
317
334
  for (let what of drop)
318
335
  flags.push(`--drop:${what}`);
336
+ if (mangleProps)
337
+ flags.push(`--mangle-props=${mangleProps.source}`);
338
+ if (reserveProps)
339
+ flags.push(`--reserve-props=${reserveProps.source}`);
319
340
  if (jsx)
320
341
  flags.push(`--jsx=${jsx}`);
321
342
  if (jsxFactory)
@@ -376,6 +397,7 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
376
397
  let write = (_a = getFlag(options, keys, "write", mustBeBoolean)) != null ? _a : writeDefault;
377
398
  let allowOverwrite = getFlag(options, keys, "allowOverwrite", mustBeBoolean);
378
399
  let incremental = getFlag(options, keys, "incremental", mustBeBoolean) === true;
400
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
379
401
  keys.plugins = true;
380
402
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
381
403
  if (sourcemap)
@@ -525,7 +547,8 @@ function flagsForBuildOptions(callName, options, isTTY, logLevelDefault, writeDe
525
547
  absWorkingDir,
526
548
  incremental,
527
549
  nodePaths,
528
- watch: watchMode
550
+ watch: watchMode,
551
+ mangleCache: validateMangleCache(mangleCache)
529
552
  };
530
553
  }
531
554
  function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
@@ -539,6 +562,7 @@ function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
539
562
  let loader = getFlag(options, keys, "loader", mustBeString);
540
563
  let banner = getFlag(options, keys, "banner", mustBeString);
541
564
  let footer = getFlag(options, keys, "footer", mustBeString);
565
+ let mangleCache = getFlag(options, keys, "mangleCache", mustBeObject);
542
566
  checkForInvalidFlags(options, keys, `in ${callName}() call`);
543
567
  if (sourcemap)
544
568
  flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
@@ -552,7 +576,10 @@ function flagsForTransformOptions(callName, options, isTTY, logLevelDefault) {
552
576
  flags.push(`--banner=${banner}`);
553
577
  if (footer)
554
578
  flags.push(`--footer=${footer}`);
555
- return flags;
579
+ return {
580
+ flags,
581
+ mangleCache: validateMangleCache(mangleCache)
582
+ };
556
583
  }
557
584
  function createChannel(streamIn) {
558
585
  let responseCallbacks = /* @__PURE__ */ new Map();
@@ -696,8 +723,8 @@ function createChannel(streamIn) {
696
723
  if (isFirstPacket) {
697
724
  isFirstPacket = false;
698
725
  let binaryVersion = String.fromCharCode(...bytes);
699
- if (binaryVersion !== "0.14.13") {
700
- throw new Error(`Cannot start service: Host version "${"0.14.13"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
726
+ if (binaryVersion !== "0.14.21") {
727
+ throw new Error(`Cannot start service: Host version "${"0.14.21"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
701
728
  }
702
729
  return;
703
730
  }
@@ -1156,7 +1183,8 @@ function createChannel(streamIn) {
1156
1183
  absWorkingDir,
1157
1184
  incremental,
1158
1185
  nodePaths,
1159
- watch
1186
+ watch,
1187
+ mangleCache
1160
1188
  } = flagsForBuildOptions(callName, options, isTTY, buildLogLevelDefault, writeDefault);
1161
1189
  let request = {
1162
1190
  command: "build",
@@ -1172,6 +1200,8 @@ function createChannel(streamIn) {
1172
1200
  };
1173
1201
  if (requestPlugins)
1174
1202
  request.plugins = requestPlugins;
1203
+ if (mangleCache)
1204
+ request.mangleCache = mangleCache;
1175
1205
  let serve2 = serveOptions && buildServeData(refs, serveOptions, request, key);
1176
1206
  let rebuild;
1177
1207
  let stop;
@@ -1180,6 +1210,8 @@ function createChannel(streamIn) {
1180
1210
  result.outputFiles = response.outputFiles.map(convertOutputFiles);
1181
1211
  if (response.metafile)
1182
1212
  result.metafile = JSON.parse(response.metafile);
1213
+ if (response.mangleCache)
1214
+ result.mangleCache = response.mangleCache;
1183
1215
  if (response.writeToStdout !== void 0)
1184
1216
  console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
1185
1217
  };
@@ -1307,20 +1339,32 @@ function createChannel(streamIn) {
1307
1339
  try {
1308
1340
  if (typeof input !== "string")
1309
1341
  throw new Error('The input to "transform" must be a string');
1310
- let flags = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);
1342
+ let {
1343
+ flags,
1344
+ mangleCache
1345
+ } = flagsForTransformOptions(callName, options, isTTY, transformLogLevelDefault);
1311
1346
  let request = {
1312
1347
  command: "transform",
1313
1348
  flags,
1314
1349
  inputFS: inputPath !== null,
1315
1350
  input: inputPath !== null ? inputPath : input
1316
1351
  };
1352
+ if (mangleCache)
1353
+ request.mangleCache = mangleCache;
1317
1354
  sendRequest(refs, request, (error, response) => {
1318
1355
  if (error)
1319
1356
  return callback(new Error(error), null);
1320
1357
  let errors = replaceDetailsInMessages(response.errors, details);
1321
1358
  let warnings = replaceDetailsInMessages(response.warnings, details);
1322
1359
  let outstanding = 1;
1323
- let next = () => --outstanding === 0 && callback(null, { warnings, code: response.code, map: response.map });
1360
+ let next = () => {
1361
+ if (--outstanding === 0) {
1362
+ let result = { warnings, code: response.code, map: response.map };
1363
+ if (response.mangleCache)
1364
+ result.mangleCache = response == null ? void 0 : response.mangleCache;
1365
+ callback(null, result);
1366
+ }
1367
+ };
1324
1368
  if (errors.length > 0)
1325
1369
  return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
1326
1370
  if (response.codeFS) {
@@ -1625,7 +1669,7 @@ function convertOutputFiles({ path, contents }) {
1625
1669
  }
1626
1670
 
1627
1671
  // lib/npm/browser.ts
1628
- var version = "0.14.13";
1672
+ var version = "0.14.21";
1629
1673
  var build = (options) => ensureServiceIsRunning().build(options);
1630
1674
  var serve = () => {
1631
1675
  throw new Error(`The "serve" API only works in node`);
@@ -2382,7 +2426,7 @@ onmessage = ({ data: wasm }) => {
2382
2426
  callback(null, count);
2383
2427
  };
2384
2428
  let go = new global.Go();
2385
- go.argv = ["", \`--service=\${"0.14.13"}\`];
2429
+ go.argv = ["", \`--service=\${"0.14.21"}\`];
2386
2430
  WebAssembly.instantiate(wasm, go.importObject).then(({ instance }) => go.run(instance));
2387
2431
  };}`;
2388
2432
  let worker;