auto-component 0.0.41 → 0.0.43

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 (2) hide show
  1. package/lib/index.js +10 -20
  2. package/package.json +2 -1
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactJsxParser = _interopRequireDefault(require("react-jsx-parser"));
10
+ var _jsBeautify = _interopRequireDefault(require("js-beautify"));
10
11
  require("./auto-component.css");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
@@ -19,7 +20,7 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
19
20
  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); }
20
21
  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; }
21
22
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
22
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint-disable no-unused-vars */ /* eslint-disable react-hooks/exhaustive-deps */ // import beautify from 'js-beautify';
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } /* eslint-disable no-unused-vars */ /* eslint-disable react-hooks/exhaustive-deps */
23
24
  var AutoComponent = function AutoComponent() {
24
25
  //**-----------**/
25
26
  // ** State ** //
@@ -72,13 +73,13 @@ var AutoComponent = function AutoComponent() {
72
73
  };
73
74
 
74
75
  // format html for display (breaks/indentation)
75
- // const formatHtml = (html) => {
76
- // return beautify.html(html, {
77
- // indent_size: 2,
78
- // wrap_line_length: 80,
79
- // max_preserve_newlines: 1,
80
- // })
81
- // }
76
+ var formatHtml = function formatHtml(html) {
77
+ return _jsBeautify["default"].html(html, {
78
+ indent_size: 2,
79
+ wrap_line_length: 80,
80
+ max_preserve_newlines: 1
81
+ });
82
+ };
82
83
 
83
84
  // clean html of exclusions:
84
85
  // if an element className includes 'exclude'
@@ -195,15 +196,6 @@ var AutoComponent = function AutoComponent() {
195
196
  return _ref.apply(this, arguments);
196
197
  };
197
198
  }();
198
- var cleanId = function cleanId(html) {
199
- var parser = new DOMParser();
200
- var doc = parser.parseFromString(html, 'text/html');
201
- var autoComponentContainer = doc.getElementById('auto-component-container');
202
- if (autoComponentContainer) {
203
- autoComponentContainer.removeAttribute('id');
204
- }
205
- return doc.documentElement.outerHTML;
206
- };
207
199
 
208
200
  // make API request with updated state data
209
201
  var handleRequest = /*#__PURE__*/function () {
@@ -219,9 +211,7 @@ var AutoComponent = function AutoComponent() {
219
211
  resData = _context2.sent;
220
212
  if (resData) {
221
213
  setHistory(resData.history);
222
- // setResponseData(formatHtml(resData.response.content));
223
- // const outputHtml = cleanId(resData.response.content)
224
- setResponseData(resData.response.content);
214
+ setResponseData(formatHtml(resData.response.content));
225
215
  setActiveTab('response');
226
216
  }
227
217
  _context2.next = 10;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "auto-component",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "main": "lib/index.js",
5
5
  "peerDependencies": {
6
6
  "react": "^18.2.0",
7
7
  "react-dom": "*",
8
+ "js-beautify": "^1.14.11",
8
9
  "react-jsx-parser": "^1.29.0"
9
10
  },
10
11
  "scripts": {