@cosmwasm/ts-codegen 0.34.1 → 0.35.0

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.
Files changed (82) hide show
  1. package/README.md +84 -21
  2. package/main/builder/builder.js +145 -247
  3. package/main/builder/index.js +0 -2
  4. package/main/bundler/bundler.js +3 -16
  5. package/main/bundler/index.js +0 -2
  6. package/main/cli.js +20 -38
  7. package/main/cmds.js +0 -5
  8. package/main/commands/create-boilerplate.js +132 -160
  9. package/main/commands/generate.js +168 -192
  10. package/main/commands/install.js +89 -123
  11. package/main/file.js +13 -25
  12. package/main/generators/client.js +55 -81
  13. package/main/generators/create-helpers.js +0 -14
  14. package/main/generators/message-composer.js +42 -68
  15. package/main/generators/msg-builder.js +49 -78
  16. package/main/generators/react-query.js +68 -92
  17. package/main/generators/recoil.js +47 -71
  18. package/main/generators/types.js +45 -73
  19. package/main/helpers/index.js +0 -6
  20. package/main/index.js +8 -30
  21. package/main/plugins/client.js +56 -90
  22. package/main/plugins/index.js +0 -2
  23. package/main/plugins/{msg-builder.js → message-builder.js} +56 -93
  24. package/main/plugins/message-composer.js +42 -76
  25. package/main/plugins/plugin-base.js +40 -70
  26. package/main/plugins/provider-bundle.js +42 -81
  27. package/main/plugins/provider.js +58 -103
  28. package/main/plugins/react-query.js +67 -99
  29. package/main/plugins/recoil.js +45 -82
  30. package/main/plugins/types.js +34 -68
  31. package/main/ts-codegen.js +7 -15
  32. package/main/utils/clean.js +8 -17
  33. package/main/utils/cleanse.js +10 -25
  34. package/main/utils/files.js +2 -22
  35. package/main/utils/header.js +0 -3
  36. package/main/utils/index.js +0 -2
  37. package/main/utils/parse.js +2 -7
  38. package/main/utils/prompt.js +16 -36
  39. package/main/utils/schemas.js +86 -133
  40. package/main/utils/unused.js +4 -15
  41. package/module/builder/builder.js +12 -33
  42. package/module/bundler/bundler.js +3 -3
  43. package/module/cli.js +0 -1
  44. package/module/commands/create-boilerplate.js +6 -19
  45. package/module/commands/generate.js +13 -18
  46. package/module/commands/install.js +14 -17
  47. package/module/file.js +0 -3
  48. package/module/generators/client.js +6 -7
  49. package/module/generators/create-helpers.js +0 -4
  50. package/module/generators/message-composer.js +4 -5
  51. package/module/generators/msg-builder.js +10 -14
  52. package/module/generators/react-query.js +8 -9
  53. package/module/generators/recoil.js +2 -3
  54. package/module/generators/types.js +4 -6
  55. package/module/plugins/client.js +4 -10
  56. package/module/plugins/{msg-builder.js → message-builder.js} +10 -18
  57. package/module/plugins/message-composer.js +4 -10
  58. package/module/plugins/plugin-base.js +10 -10
  59. package/module/plugins/provider-bundle.js +0 -10
  60. package/module/plugins/provider.js +0 -14
  61. package/module/plugins/react-query.js +8 -13
  62. package/module/plugins/recoil.js +2 -9
  63. package/module/plugins/types.js +4 -7
  64. package/module/ts-codegen.js +0 -2
  65. package/module/utils/clean.js +8 -13
  66. package/module/utils/cleanse.js +10 -21
  67. package/module/utils/files.js +2 -6
  68. package/module/utils/parse.js +2 -4
  69. package/module/utils/prompt.js +0 -5
  70. package/module/utils/schemas.js +2 -13
  71. package/module/utils/unused.js +4 -6
  72. package/package.json +3 -3
  73. package/src/builder/builder.ts +7 -6
  74. package/src/commands/generate.ts +13 -12
  75. package/src/generators/msg-builder.ts +7 -9
  76. package/src/plugins/{msg-builder.ts → message-builder.ts} +6 -6
  77. package/src/plugins/message-composer.ts +2 -2
  78. package/types/src/builder/builder.d.ts +3 -2
  79. package/types/src/generators/msg-builder.d.ts +2 -2
  80. package/types/src/generators/msg-builder.ts +2 -2
  81. package/types/src/plugins/message-builder.d.ts +12 -0
  82. package/types/src/plugins/msg-builder.d.ts +1 -1
@@ -1,88 +1,54 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.TSBuilder = void 0;
11
-
12
9
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
13
-
14
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
15
-
16
11
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
17
-
18
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
19
-
20
13
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
21
-
22
14
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
23
-
24
15
  var _wasmAstTypes = require("wasm-ast-types");
25
-
26
16
  var _header = require("../utils/header");
27
-
28
17
  var _path = require("path");
29
-
30
18
  var _fs = require("fs");
31
-
32
19
  var _mkdirp = require("mkdirp");
33
-
34
20
  var _utils = require("../utils");
35
-
36
21
  var _deepmerge = _interopRequireDefault(require("deepmerge"));
37
-
38
22
  var _case = require("case");
39
-
40
23
  var _bundler = require("../bundler");
41
-
42
24
  var _generator = _interopRequireDefault(require("@babel/generator"));
43
-
44
25
  var t = _interopRequireWildcard(require("@babel/types"));
45
-
46
26
  var _reactQuery = require("../plugins/react-query");
47
-
48
27
  var _recoil = require("../plugins/recoil");
49
-
50
- var _msgBuilder = require("../plugins/msg-builder");
51
-
28
+ var _messageBuilder = require("../plugins/message-builder");
52
29
  var _messageComposer = require("../plugins/message-composer");
53
-
54
30
  var _client = require("../plugins/client");
55
-
56
31
  var _types2 = require("../plugins/types");
57
-
58
32
  var _provider = require("../plugins/provider");
59
-
60
33
  var _createHelpers = require("../generators/create-helpers");
61
-
62
34
  var _providerBundle = require("../plugins/provider-bundle");
63
-
64
35
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
65
-
66
36
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
67
-
68
37
  function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
69
-
70
38
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
71
-
72
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
73
-
39
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
74
40
  var defaultOpts = {
75
41
  bundle: {
76
42
  enabled: true,
77
43
  scope: 'contracts',
78
44
  bundleFile: 'bundle.ts'
79
- }
45
+ },
46
+ useShorthandCtor: true
80
47
  };
81
48
  ;
82
49
  ;
83
50
  ;
84
51
  ;
85
-
86
52
  function getContract(contractOpt) {
87
53
  if (typeof contractOpt === 'string') {
88
54
  var name = (0, _path.basename)(contractOpt);
@@ -92,21 +58,18 @@ function getContract(contractOpt) {
92
58
  dir: contractOpt
93
59
  };
94
60
  }
95
-
96
61
  return {
97
62
  name: (0, _case.pascal)(contractOpt.name),
98
63
  dir: contractOpt.dir
99
64
  };
100
65
  }
101
-
102
66
  var TSBuilder = /*#__PURE__*/function () {
103
67
  function TSBuilder(_ref) {
104
68
  var _this = this;
105
-
106
69
  var contracts = _ref.contracts,
107
- outPath = _ref.outPath,
108
- options = _ref.options,
109
- plugins = _ref.plugins;
70
+ outPath = _ref.outPath,
71
+ options = _ref.options,
72
+ plugins = _ref.plugins;
110
73
  (0, _classCallCheck2["default"])(this, TSBuilder);
111
74
  (0, _defineProperty2["default"])(this, "contracts", void 0);
112
75
  (0, _defineProperty2["default"])(this, "outPath", void 0);
@@ -118,118 +81,90 @@ var TSBuilder = /*#__PURE__*/function () {
118
81
  this.outPath = outPath;
119
82
  this.options = (0, _deepmerge["default"])((0, _deepmerge["default"])(_wasmAstTypes.defaultOptions, defaultOpts), options !== null && options !== void 0 ? options : {});
120
83
  this.loadDefaultPlugins();
121
-
122
84
  if (plugins && plugins.length) {
123
85
  [].push.apply(this.plugins, plugins);
124
86
  }
125
-
126
87
  this.plugins.forEach(function (plugin) {
127
88
  return plugin.setBuilder(_this);
128
89
  });
129
90
  }
130
-
131
91
  (0, _createClass2["default"])(TSBuilder, [{
132
92
  key: "loadDefaultPlugins",
133
93
  value: function loadDefaultPlugins() {
134
- [].push.apply(this.plugins, [new _types2.TypesPlugin(this.options), new _client.ClientPlugin(this.options), new _messageComposer.MessageComposerPlugin(this.options), new _reactQuery.ReactQueryPlugin(this.options), new _recoil.RecoilPlugin(this.options), new _msgBuilder.MsgBuilderPlugin(this.options), new _provider.ContractsContextProviderPlugin(this.options)]);
94
+ [].push.apply(this.plugins, [new _types2.TypesPlugin(this.options), new _client.ClientPlugin(this.options), new _messageComposer.MessageComposerPlugin(this.options), new _reactQuery.ReactQueryPlugin(this.options), new _recoil.RecoilPlugin(this.options), new _messageBuilder.MessageBuilderPlugin(this.options), new _provider.ContractsContextProviderPlugin(this.options)]);
135
95
  }
136
96
  }, {
137
97
  key: "build",
138
98
  value: function () {
139
99
  var _build = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
140
100
  return _regenerator["default"].wrap(function _callee$(_context) {
141
- while (1) {
142
- switch (_context.prev = _context.next) {
143
- case 0:
144
- _context.next = 2;
145
- return this.process();
146
-
147
- case 2:
148
- _context.next = 4;
149
- return this.after();
150
-
151
- case 4:
152
- case "end":
153
- return _context.stop();
154
- }
101
+ while (1) switch (_context.prev = _context.next) {
102
+ case 0:
103
+ _context.next = 2;
104
+ return this.process();
105
+ case 2:
106
+ _context.next = 4;
107
+ return this.after();
108
+ case 4:
109
+ case "end":
110
+ return _context.stop();
155
111
  }
156
112
  }, _callee, this);
157
113
  }));
158
-
159
114
  function build() {
160
115
  return _build.apply(this, arguments);
161
116
  }
162
-
163
117
  return build;
164
118
  }() // lifecycle functions
165
-
166
119
  }, {
167
120
  key: "process",
168
121
  value: function () {
169
122
  var _process = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
170
123
  var _iterator, _step, contractOpt, contract, contractInfo;
171
-
172
124
  return _regenerator["default"].wrap(function _callee2$(_context2) {
173
- while (1) {
174
- switch (_context2.prev = _context2.next) {
175
- case 0:
176
- _iterator = _createForOfIteratorHelper(this.contracts);
177
- _context2.prev = 1;
178
-
179
- _iterator.s();
180
-
181
- case 3:
182
- if ((_step = _iterator.n()).done) {
183
- _context2.next = 13;
184
- break;
185
- }
186
-
187
- contractOpt = _step.value;
188
- contract = getContract(contractOpt); //resolve contract schema.
189
-
190
- _context2.next = 8;
191
- return (0, _utils.readSchemas)({
192
- schemaDir: contract.dir
193
- });
194
-
195
- case 8:
196
- contractInfo = _context2.sent;
197
- _context2.next = 11;
198
- return this.render(contract.name, contractInfo);
199
-
200
- case 11:
201
- _context2.next = 3;
202
- break;
203
-
204
- case 13:
205
- _context2.next = 18;
125
+ while (1) switch (_context2.prev = _context2.next) {
126
+ case 0:
127
+ _iterator = _createForOfIteratorHelper(this.contracts);
128
+ _context2.prev = 1;
129
+ _iterator.s();
130
+ case 3:
131
+ if ((_step = _iterator.n()).done) {
132
+ _context2.next = 13;
206
133
  break;
207
-
208
- case 15:
209
- _context2.prev = 15;
210
- _context2.t0 = _context2["catch"](1);
211
-
212
- _iterator.e(_context2.t0);
213
-
214
- case 18:
215
- _context2.prev = 18;
216
-
217
- _iterator.f();
218
-
219
- return _context2.finish(18);
220
-
221
- case 21:
222
- case "end":
223
- return _context2.stop();
224
- }
134
+ }
135
+ contractOpt = _step.value;
136
+ contract = getContract(contractOpt); //resolve contract schema.
137
+ _context2.next = 8;
138
+ return (0, _utils.readSchemas)({
139
+ schemaDir: contract.dir
140
+ });
141
+ case 8:
142
+ contractInfo = _context2.sent;
143
+ _context2.next = 11;
144
+ return this.render(contract.name, contractInfo);
145
+ case 11:
146
+ _context2.next = 3;
147
+ break;
148
+ case 13:
149
+ _context2.next = 18;
150
+ break;
151
+ case 15:
152
+ _context2.prev = 15;
153
+ _context2.t0 = _context2["catch"](1);
154
+ _iterator.e(_context2.t0);
155
+ case 18:
156
+ _context2.prev = 18;
157
+ _iterator.f();
158
+ return _context2.finish(18);
159
+ case 21:
160
+ case "end":
161
+ return _context2.stop();
225
162
  }
226
163
  }, _callee2, this, [[1, 15, 18, 21]]);
227
164
  }));
228
-
229
165
  function process() {
230
166
  return _process.apply(this, arguments);
231
167
  }
232
-
233
168
  return process;
234
169
  }()
235
170
  }, {
@@ -237,66 +172,48 @@ var TSBuilder = /*#__PURE__*/function () {
237
172
  value: function () {
238
173
  var _render = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(name, contractInfo) {
239
174
  var _iterator2, _step2, plugin, files;
240
-
241
175
  return _regenerator["default"].wrap(function _callee3$(_context3) {
242
- while (1) {
243
- switch (_context3.prev = _context3.next) {
244
- case 0:
245
- _iterator2 = _createForOfIteratorHelper(this.plugins);
246
- _context3.prev = 1;
247
-
248
- _iterator2.s();
249
-
250
- case 3:
251
- if ((_step2 = _iterator2.n()).done) {
252
- _context3.next = 11;
253
- break;
254
- }
255
-
256
- plugin = _step2.value;
257
- _context3.next = 7;
258
- return plugin.render(name, contractInfo, this.outPath);
259
-
260
- case 7:
261
- files = _context3.sent;
262
-
263
- if (files && files.length) {
264
- [].push.apply(this.files, files);
265
- }
266
-
267
- case 9:
268
- _context3.next = 3;
176
+ while (1) switch (_context3.prev = _context3.next) {
177
+ case 0:
178
+ _iterator2 = _createForOfIteratorHelper(this.plugins);
179
+ _context3.prev = 1;
180
+ _iterator2.s();
181
+ case 3:
182
+ if ((_step2 = _iterator2.n()).done) {
183
+ _context3.next = 11;
269
184
  break;
270
-
271
- case 11:
272
- _context3.next = 16;
273
- break;
274
-
275
- case 13:
276
- _context3.prev = 13;
277
- _context3.t0 = _context3["catch"](1);
278
-
279
- _iterator2.e(_context3.t0);
280
-
281
- case 16:
282
- _context3.prev = 16;
283
-
284
- _iterator2.f();
285
-
286
- return _context3.finish(16);
287
-
288
- case 19:
289
- case "end":
290
- return _context3.stop();
291
- }
185
+ }
186
+ plugin = _step2.value;
187
+ _context3.next = 7;
188
+ return plugin.render(name, contractInfo, this.outPath);
189
+ case 7:
190
+ files = _context3.sent;
191
+ if (files && files.length) {
192
+ [].push.apply(this.files, files);
193
+ }
194
+ case 9:
195
+ _context3.next = 3;
196
+ break;
197
+ case 11:
198
+ _context3.next = 16;
199
+ break;
200
+ case 13:
201
+ _context3.prev = 13;
202
+ _context3.t0 = _context3["catch"](1);
203
+ _iterator2.e(_context3.t0);
204
+ case 16:
205
+ _context3.prev = 16;
206
+ _iterator2.f();
207
+ return _context3.finish(16);
208
+ case 19:
209
+ case "end":
210
+ return _context3.stop();
292
211
  }
293
212
  }, _callee3, this, [[1, 13, 16, 19]]);
294
213
  }));
295
-
296
214
  function render(_x, _x2) {
297
215
  return _render.apply(this, arguments);
298
216
  }
299
-
300
217
  return render;
301
218
  }()
302
219
  }, {
@@ -305,52 +222,43 @@ var TSBuilder = /*#__PURE__*/function () {
305
222
  var _after = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
306
223
  var contractsProviderBundlePlugin, files, helpers;
307
224
  return _regenerator["default"].wrap(function _callee4$(_context4) {
308
- while (1) {
309
- switch (_context4.prev = _context4.next) {
310
- case 0:
311
- //create useContracts bundle file
312
- contractsProviderBundlePlugin = new _providerBundle.ContractsProviderBundlePlugin(this.options);
313
- contractsProviderBundlePlugin.setBuilder(this); //contractContextProviders.ts
314
-
315
- _context4.next = 4;
316
- return contractsProviderBundlePlugin.render("contractContextProviders", {
317
- schemas: []
318
- }, this.outPath);
319
-
320
- case 4:
321
- files = _context4.sent;
322
-
323
- if (files && files.length) {
324
- [].push.apply(this.files, files);
325
- }
326
-
327
- helpers = (0, _createHelpers.createHelpers)({
328
- outPath: this.outPath,
329
- contracts: this.contracts,
330
- options: this.options,
331
- plugins: this.plugins
332
- }, this.builderContext);
333
-
334
- if (helpers && helpers.length) {
335
- [].push.apply(this.files, helpers);
336
- }
337
-
338
- if (this.options.bundle.enabled) {
339
- this.bundle();
340
- }
341
-
342
- case 9:
343
- case "end":
344
- return _context4.stop();
345
- }
225
+ while (1) switch (_context4.prev = _context4.next) {
226
+ case 0:
227
+ //create useContracts bundle file
228
+ contractsProviderBundlePlugin = new _providerBundle.ContractsProviderBundlePlugin(this.options);
229
+ contractsProviderBundlePlugin.setBuilder(this);
230
+
231
+ //contractContextProviders.ts
232
+ _context4.next = 4;
233
+ return contractsProviderBundlePlugin.render("contractContextProviders", {
234
+ schemas: []
235
+ }, this.outPath);
236
+ case 4:
237
+ files = _context4.sent;
238
+ if (files && files.length) {
239
+ [].push.apply(this.files, files);
240
+ }
241
+ helpers = (0, _createHelpers.createHelpers)({
242
+ outPath: this.outPath,
243
+ contracts: this.contracts,
244
+ options: this.options,
245
+ plugins: this.plugins
246
+ }, this.builderContext);
247
+ if (helpers && helpers.length) {
248
+ [].push.apply(this.files, helpers);
249
+ }
250
+ if (this.options.bundle.enabled) {
251
+ this.bundle();
252
+ }
253
+ case 9:
254
+ case "end":
255
+ return _context4.stop();
346
256
  }
347
257
  }, _callee4, this);
348
258
  }));
349
-
350
259
  function after() {
351
260
  return _after.apply(this, arguments);
352
261
  }
353
-
354
262
  return after;
355
263
  }()
356
264
  }, {
@@ -358,53 +266,43 @@ var TSBuilder = /*#__PURE__*/function () {
358
266
  value: function () {
359
267
  var _bundle = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
360
268
  var _this$options$bundle$,
361
- _this$options,
362
- _this$options$bundle,
363
- _this2 = this,
364
- _this$options2,
365
- _this$options2$bundle;
366
-
269
+ _this$options,
270
+ _this$options$bundle,
271
+ _this2 = this,
272
+ _this$options2,
273
+ _this$options2$bundle;
367
274
  var allFiles, bundleFile, bundlePath, bundleVariables, importPaths, ast, code, _this$options3, _this$options3$bundle;
368
-
369
275
  return _regenerator["default"].wrap(function _callee5$(_context5) {
370
- while (1) {
371
- switch (_context5.prev = _context5.next) {
372
- case 0:
373
- allFiles = this.files;
374
- bundleFile = this.options.bundle.bundleFile;
375
- bundlePath = (0, _path.join)((_this$options$bundle$ = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$bundle = _this$options.bundle) === null || _this$options$bundle === void 0 ? void 0 : _this$options$bundle.bundlePath) !== null && _this$options$bundle$ !== void 0 ? _this$options$bundle$ : this.outPath, bundleFile);
376
- bundleVariables = {};
377
- importPaths = [];
378
- allFiles.forEach(function (file) {
379
- (0, _bundler.createFileBundle)("".concat(_this2.options.bundle.scope, ".").concat(file.contract), file.filename, bundlePath, importPaths, bundleVariables);
380
- });
381
- ast = (0, _bundler.recursiveModuleBundle)(bundleVariables);
382
- code = (0, _generator["default"])(t.program([].concat(importPaths, (0, _toConsumableArray2["default"])(ast)))).code;
383
-
384
- if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && (_this$options2$bundle = _this$options2.bundle) !== null && _this$options2$bundle !== void 0 && _this$options2$bundle.bundlePath) {
385
- (0, _mkdirp.sync)((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : (_this$options3$bundle = _this$options3.bundle) === null || _this$options3$bundle === void 0 ? void 0 : _this$options3$bundle.bundlePath);
386
- }
387
-
388
- (0, _mkdirp.sync)(this.outPath);
389
- if (code.trim() === '') code = 'export {};';
390
- (0, _fs.writeFileSync)(bundlePath, _header.header + code);
391
-
392
- case 12:
393
- case "end":
394
- return _context5.stop();
395
- }
276
+ while (1) switch (_context5.prev = _context5.next) {
277
+ case 0:
278
+ allFiles = this.files;
279
+ bundleFile = this.options.bundle.bundleFile;
280
+ bundlePath = (0, _path.join)((_this$options$bundle$ = (_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$bundle = _this$options.bundle) === null || _this$options$bundle === void 0 ? void 0 : _this$options$bundle.bundlePath) !== null && _this$options$bundle$ !== void 0 ? _this$options$bundle$ : this.outPath, bundleFile);
281
+ bundleVariables = {};
282
+ importPaths = [];
283
+ allFiles.forEach(function (file) {
284
+ (0, _bundler.createFileBundle)("".concat(_this2.options.bundle.scope, ".").concat(file.contract), file.filename, bundlePath, importPaths, bundleVariables);
285
+ });
286
+ ast = (0, _bundler.recursiveModuleBundle)(bundleVariables);
287
+ code = (0, _generator["default"])(t.program([].concat(importPaths, (0, _toConsumableArray2["default"])(ast)))).code;
288
+ if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && (_this$options2$bundle = _this$options2.bundle) !== null && _this$options2$bundle !== void 0 && _this$options2$bundle.bundlePath) {
289
+ (0, _mkdirp.sync)((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : (_this$options3$bundle = _this$options3.bundle) === null || _this$options3$bundle === void 0 ? void 0 : _this$options3$bundle.bundlePath);
290
+ }
291
+ (0, _mkdirp.sync)(this.outPath);
292
+ if (code.trim() === '') code = 'export {};';
293
+ (0, _fs.writeFileSync)(bundlePath, _header.header + code);
294
+ case 12:
295
+ case "end":
296
+ return _context5.stop();
396
297
  }
397
298
  }, _callee5, this);
398
299
  }));
399
-
400
300
  function bundle() {
401
301
  return _bundle.apply(this, arguments);
402
302
  }
403
-
404
303
  return bundle;
405
304
  }()
406
305
  }]);
407
306
  return TSBuilder;
408
307
  }();
409
-
410
308
  exports.TSBuilder = TSBuilder;
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _builder = require("./builder");
8
-
9
7
  Object.keys(_builder).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _builder[key]) return;
@@ -1,31 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _typeof = require("@babel/runtime/helpers/typeof");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.recursiveModuleBundle = exports.importNamespace = exports.createFileBundle = void 0;
9
-
10
8
  var t = _interopRequireWildcard(require("@babel/types"));
11
-
12
9
  var dotty = _interopRequireWildcard(require("dotty"));
13
-
14
10
  var _path = require("path");
15
-
16
11
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
12
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
13
  var recursiveModuleBundle = function recursiveModuleBundle(obj) {
21
14
  return Object.keys(obj).map(function (key) {
22
15
  var _obj$key;
23
-
24
16
  if ((_obj$key = obj[key]) !== null && _obj$key !== void 0 && _obj$key.__export) {
25
17
  // e.g. abci
26
18
  // 1. create variable for abci
27
19
  // 2. splat ALL _0, parms into abci
28
20
  // 3. export that variable
21
+
29
22
  var nmspc = t.variableDeclaration('const', [t.variableDeclarator(t.identifier(key), t.objectExpression(Object.keys(obj[key]).filter(function (a) {
30
23
  return a !== '__export';
31
24
  }).filter(function (a) {
@@ -38,12 +31,11 @@ var recursiveModuleBundle = function recursiveModuleBundle(obj) {
38
31
  }).filter(function (a) {
39
32
  return !a.startsWith('_');
40
33
  });
41
-
42
34
  if (others.length) {
43
35
  throw new Error('namespace and package not supported, yet.');
44
- } // return nmspc;
45
-
36
+ }
46
37
 
38
+ // return nmspc;
47
39
  return t.exportNamedDeclaration(nmspc, []);
48
40
  } else {
49
41
  // you can make a namespace for obj[key]
@@ -52,16 +44,12 @@ var recursiveModuleBundle = function recursiveModuleBundle(obj) {
52
44
  }
53
45
  });
54
46
  };
55
-
56
47
  exports.recursiveModuleBundle = recursiveModuleBundle;
57
-
58
48
  var importNamespace = function importNamespace(ident, path) {
59
49
  return t.importDeclaration([t.importNamespaceSpecifier(t.identifier(ident))], t.stringLiteral(path.replace((0, _path.extname)(path), '')));
60
50
  };
61
-
62
51
  exports.importNamespace = importNamespace;
63
52
  var counter = 0;
64
-
65
53
  var createFileBundle = function createFileBundle(pkg, filename, bundleFile, importPaths, bundleVariables) {
66
54
  var rel = (0, _path.relative)((0, _path.dirname)(bundleFile), filename);
67
55
  if (!rel.startsWith('.')) rel = "./".concat(rel);
@@ -70,5 +58,4 @@ var createFileBundle = function createFileBundle(pkg, filename, bundleFile, impo
70
58
  dotty.put(bundleVariables, pkg + '.__export', true);
71
59
  dotty.put(bundleVariables, pkg + '.' + variable, true);
72
60
  };
73
-
74
61
  exports.createFileBundle = createFileBundle;
@@ -3,9 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
-
7
6
  var _bundler = require("./bundler");
8
-
9
7
  Object.keys(_bundler).forEach(function (key) {
10
8
  if (key === "default" || key === "__esModule") return;
11
9
  if (key in exports && exports[key] === _bundler[key]) return;