1 | "use strict";
|
2 |
|
3 | require("core-js/modules/es.array.concat");
|
4 |
|
5 | require("core-js/modules/es.array.map");
|
6 |
|
7 | require("core-js/modules/es.object.to-string");
|
8 |
|
9 | require("core-js/modules/es.promise");
|
10 |
|
11 | require("core-js/modules/es.regexp.exec");
|
12 |
|
13 | require("core-js/modules/es.string.split");
|
14 |
|
15 | Object.defineProperty(exports, "__esModule", {
|
16 | value: true
|
17 | });
|
18 | exports.transform = transform;
|
19 |
|
20 | require("regenerator-runtime/runtime");
|
21 |
|
22 | var _sourceMap = require("source-map");
|
23 |
|
24 | var _readAsObject = require("./dependencies-lookup/readAsObject");
|
25 |
|
26 | function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
27 |
|
28 | function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
29 |
|
30 | function transform(_x, _x2) {
|
31 | return _transform.apply(this, arguments);
|
32 | }
|
33 |
|
34 | function _transform() {
|
35 | _transform = _asyncToGenerator( regeneratorRuntime.mark(function _callee(inputSource, inputSourceMap) {
|
36 | var _this = this;
|
37 |
|
38 | var callback, sourceObject, source, sourceJson, addsMap, sourceNode, preamble, _sourceNode$toStringW, code, map;
|
39 |
|
40 | return regeneratorRuntime.wrap(function _callee$(_context) {
|
41 | while (1) {
|
42 | switch (_context.prev = _context.next) {
|
43 | case 0:
|
44 | callback = this.async();
|
45 | _context.prev = 1;
|
46 | _context.next = 4;
|
47 | return (0, _readAsObject.readStory)(this, inputSource);
|
48 |
|
49 | case 4:
|
50 | sourceObject = _context.sent;
|
51 |
|
52 | if (!(!sourceObject.source || sourceObject.source.length === 0)) {
|
53 | _context.next = 8;
|
54 | break;
|
55 | }
|
56 |
|
57 | callback(null, inputSource, inputSourceMap);
|
58 | return _context.abrupt("return");
|
59 |
|
60 | case 8:
|
61 | source = sourceObject.source, sourceJson = sourceObject.sourceJson, addsMap = sourceObject.addsMap;
|
62 |
|
63 |
|
64 | if (!inputSourceMap) {
|
65 | _context.next = 15;
|
66 | break;
|
67 | }
|
68 |
|
69 | _context.next = 12;
|
70 | return _sourceMap.SourceMapConsumer["with"](JSON.stringify(inputSourceMap), null, function (consumer) {
|
71 | return _sourceMap.SourceNode.fromStringWithSourceMap(source, consumer);
|
72 | });
|
73 |
|
74 | case 12:
|
75 | sourceNode = _context.sent;
|
76 | _context.next = 18;
|
77 | break;
|
78 |
|
79 | case 15:
|
80 |
|
81 |
|
82 |
|
83 | sourceNode = new _sourceMap.SourceNode();
|
84 | sourceNode.add(source.split(/\n/).map(function (line, index) {
|
85 | return new _sourceMap.SourceNode(index + 1, 0, _this.resourcePath, "".concat(line, "\n"));
|
86 | }));
|
87 | sourceNode.setSourceContent(this.resourcePath, inputSource);
|
88 |
|
89 | case 18:
|
90 |
|
91 | preamble = "\n /* eslint-disable */\n // @ts-nocheck\n // @ts-ignore\n var __STORY__ = ".concat(sourceJson, ";\n // @ts-ignore\n var __LOCATIONS_MAP__ = ").concat(JSON.stringify(addsMap), ";");
|
92 | sourceNode.prepend("".concat(preamble, "\n"));
|
93 |
|
94 | _sourceNode$toStringW = sourceNode.toStringWithSourceMap(), code = _sourceNode$toStringW.code, map = _sourceNode$toStringW.map;
|
95 | callback(null, code, map);
|
96 | _context.next = 27;
|
97 | break;
|
98 |
|
99 | case 24:
|
100 | _context.prev = 24;
|
101 | _context.t0 = _context["catch"](1);
|
102 | callback(_context.t0);
|
103 |
|
104 | case 27:
|
105 | case "end":
|
106 | return _context.stop();
|
107 | }
|
108 | }
|
109 | }, _callee, this, [[1, 24]]);
|
110 | }));
|
111 | return _transform.apply(this, arguments);
|
112 | } |
\ | No newline at end of file |