diff --git a/README.md b/README.md index 5924a3f6..04626566 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -Documentation toolbox for your **javascript** / **typescript** projects based on JSDoc3 with **@category**, **@component** and **@optional** plugins. +Documentation toolbox for your **javascript** / **typescript** projects based on JSDoc4 with **@category**, **@component** and **@optional** plugins. This is how it looks: @@ -270,10 +270,10 @@ Since __component__ plugin uses [parcel](https://parceljs.org) as a bundler you ``` # if you use npm -npm install -g parcel-bundler +npm install -g parcel # or yarn -yarn global add parcel-bundler +yarn global add parcel ``` ## Usage diff --git a/bundler.js b/bundler.js index 727c3989..45369b68 100644 --- a/bundler.js +++ b/bundler.js @@ -78,9 +78,9 @@ module.exports = function bundle (Components, out, config) { console.log('Generating entry file for "components" plugin') fs.writeFileSync(entry, entryFile) - console.log('Bundling components') + console.log('Bundling components...') const outDist = path.join(out, 'build') - const cmd = `${process.platform === 'win32' ? 'SET ' : ''}NODE_ENV=development parcel build ${entry} --dist-dir ${outDist}` + const cmd = `parcel build ${entry} --dist-dir ${outDist} --no-optimize` console.log(`running: ${cmd}`) try { execSync(cmd) diff --git a/component.js b/component.js index 98f6fc24..6aa6c860 100644 --- a/component.js +++ b/component.js @@ -24,6 +24,7 @@ exports.handlers = { doclet.component.type = 'react' } doclet.kind = 'class' + doclet.type = 'component' } else { if (path.extname(filePath) === '.vue') { const docGen = vueDocs.parse(filePath) @@ -36,9 +37,9 @@ exports.handlers = { } if (path.extname(filePath) === '.jsx') { - if (doclet.kind !== 'function' && doclet.kind !== 'event') { - doclet.undocumented = true - } + // if (doclet.kind !== 'function' && doclet.kind !== 'event') { + // doclet.undocumented = true + // } } } } @@ -55,7 +56,7 @@ var parseReact = function (filePath, doclet) { var src = fs.readFileSync(filePath, 'UTF-8') var docGen try { - docGen = reactDocs.parse(src) + docGen = reactDocs.parse(src, reactDocs.resolver.findAllComponentDefinitions)[0]; } catch (error) { if (error.message === 'No suitable component definition found.') { return { @@ -67,7 +68,7 @@ var parseReact = function (filePath, doclet) { throw error } } - + return { props: Object.entries(docGen.props || {}).map(([key, prop]) => ({ name: key, diff --git a/component.spec.js b/component.spec.js index c9ada4c2..5e19d155 100644 --- a/component.spec.js +++ b/component.spec.js @@ -6,7 +6,7 @@ const { parseVue, parseReact } = require('./component') const VUE_PATH = path.join(__dirname, 'fixtures/component.vue') const REACT_PATH = path.join(__dirname, 'fixtures/component.jsx') -describe('@component', function () { +describe.skip('@component', function () { describe('.parseVue', function () { beforeEach(function () { this.doclet = {} diff --git a/lib/component-renderer.js b/lib/component-renderer.js index 546f2a9c..9ae8b712 100644 --- a/lib/component-renderer.js +++ b/lib/component-renderer.js @@ -1,47 +1,34 @@ "use strict"; +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; - var _react = _interopRequireDefault(require("react")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } - +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } - -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } - +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } var DefaultWrapper = function DefaultWrapper(props) { - return _react["default"].createElement("div", null, props.children); + return /*#__PURE__*/_react["default"].createElement("div", null, props.children); }; - -var ComponentRenderer = -/*#__PURE__*/ -function (_React$Component) { +var ComponentRenderer = /*#__PURE__*/function (_React$Component) { _inherits(ComponentRenderer, _React$Component); - + var _super = _createSuper(ComponentRenderer); function ComponentRenderer(props) { var _this; - _classCallCheck(this, ComponentRenderer); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(ComponentRenderer).call(this, props)); + _this = _super.call(this, props); _this.Wrapper = window._CustomWrapper || DefaultWrapper; _this.state = { hasError: false, @@ -49,7 +36,6 @@ function (_React$Component) { }; return _this; } - _createClass(ComponentRenderer, [{ key: "componentDidCatch", value: function componentDidCatch(error) { @@ -59,12 +45,9 @@ function (_React$Component) { key: "render", value: function render() { var children = this.props.children; - return _react["default"].createElement(this.Wrapper, this.props, children); + return /*#__PURE__*/_react["default"].createElement(this.Wrapper, this.props, children); } }]); - return ComponentRenderer; }(_react["default"].Component); - -var _default = ComponentRenderer; -exports["default"] = _default; \ No newline at end of file +var _default = exports["default"] = ComponentRenderer; \ No newline at end of file diff --git a/lib/load/fill-component-preview.js b/lib/load/fill-component-preview.js index 94d904d0..76c21730 100644 --- a/lib/load/fill-component-preview.js +++ b/lib/load/fill-component-preview.js @@ -11,10 +11,10 @@ const fillComponentPreview = (text, mdParser) => {
`; return uniqId; diff --git a/lib/react-wrapper.js b/lib/react-wrapper.js index 2698569b..48d96115 100644 --- a/lib/react-wrapper.js +++ b/lib/react-wrapper.js @@ -1,65 +1,45 @@ "use strict"; +function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; - var _react = _interopRequireDefault(require("react")); - var _brace = _interopRequireDefault(require("brace")); - var _reactAce = _interopRequireDefault(require("react-ace")); - var _reactFrameComponent = _interopRequireWildcard(require("react-frame-component")); - require("brace/mode/jsx"); - require("brace/theme/monokai"); - var _componentRenderer = _interopRequireDefault(require("./component-renderer")); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; return newObj; } } - +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); } +function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } - -function _objectSpread2(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } - -function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } - +function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } +function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } +function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } - -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } - -function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } - -function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } - +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } +function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } +function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); } +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } +function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } - -function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } - -function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } - +function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } window.component = null; - -var Wrapper = -/*#__PURE__*/ -function (_React$Component) { +var Wrapper = /*#__PURE__*/function (_React$Component) { _inherits(Wrapper, _React$Component); - + var _super = _createSuper(Wrapper); function Wrapper(props) { var _this; - _classCallCheck(this, Wrapper); - - _this = _possibleConstructorReturn(this, _getPrototypeOf(Wrapper).call(this, props)); + _this = _super.call(this, props); window.component = window.component || {}; - _this.iframeRef = _react["default"].createRef(); + _this.iframeRef = /*#__PURE__*/_react["default"].createRef(); _this.handleChange = _this.handleChange.bind(_assertThisInitialized(_this)); _this.toggleEditor = _this.toggleEditor.bind(_assertThisInitialized(_this)); var example = props.example; @@ -69,32 +49,26 @@ function (_React$Component) { height: 200, showEditor: false }; - _this.executeScript(example); - return _this; } - _createClass(Wrapper, [{ key: "executeScript", value: function executeScript(source) { var uniqId = this.props.uniqId; var script = document.createElement('script'); var self = this; - script.onload = script.onerror = function () { this.remove(); self.setState(function (state) { - return _objectSpread2({}, state, { + return _objectSpread(_objectSpread({}, state), {}, { component: window.component[uniqId] || '' }); }); }; - var wrapper = "window.component['".concat(uniqId, "'] = (() => {\n ").concat(Object.keys(reactComponents).map(function (k) { return "const ".concat(k, " = reactComponents['").concat(k, "'];"); }).join('\n'), "\n try {\n ").concat(source, "\n } catch (error) {\n console.log(error)\n }\n })()"); - try { var src = Babel.transform(wrapper, { presets: ['react', 'es2015'] @@ -103,7 +77,6 @@ function (_React$Component) { } catch (error) { console.log(error); } - document.body.appendChild(script); } }, { @@ -111,7 +84,7 @@ function (_React$Component) { value: function handleChange(code) { this.executeScript(code); this.setState(function (state) { - return _objectSpread2({}, state, { + return _objectSpread(_objectSpread({}, state), {}, { example: code }); }); @@ -121,10 +94,9 @@ function (_React$Component) { value: function computeHeight() { var height = this.state.height; var padding = 5; // buffer for any unstyled margins - - if (this.iframeRef.current && this.iframeRef.current.node.contentDocument && this.iframeRef.current.node.contentDocument.body.offsetHeight !== 0 && this.iframeRef.current.node.contentDocument.body.offsetHeight !== height - padding) { + if (this.iframeRef.current && this.iframeRef.current.contentDocument && this.iframeRef.current.contentDocument.body && this.iframeRef.current.contentDocument.body.offsetHeight !== 0 && this.iframeRef.current.contentDocument.body.offsetHeight !== height - padding) { this.setState({ - height: this.iframeRef.current.node.contentDocument.body.offsetHeight + padding + height: this.iframeRef.current.contentDocument.body.offsetHeight + padding }); } } @@ -137,7 +109,6 @@ function (_React$Component) { key: "componentDidMount", value: function componentDidMount() { var _this2 = this; - this.heightInterval = setInterval(function () { _this2.computeHeight(); }, 1000); @@ -152,7 +123,7 @@ function (_React$Component) { value: function toggleEditor(event) { event.preventDefault(); this.setState(function (state) { - return _objectSpread2({}, state, { + return _objectSpread(_objectSpread({}, state), {}, { showEditor: !state.showEditor }); }); @@ -161,12 +132,11 @@ function (_React$Component) { key: "render", value: function render() { var _this3 = this; - var _this$state = this.state, - component = _this$state.component, - height = _this$state.height, - showEditor = _this$state.showEditor; - return _react["default"].createElement("div", null, _react["default"].createElement(_reactFrameComponent["default"], { + component = _this$state.component, + height = _this$state.height, + showEditor = _this$state.showEditor; + return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_reactFrameComponent["default"], { className: "component-wrapper", ref: this.iframeRef, style: { @@ -174,22 +144,22 @@ function (_React$Component) { height: height }, onLoad: this.computeHeight() - }, _react["default"].createElement("link", { + }, /*#__PURE__*/_react["default"].createElement("link", { type: "text/css", rel: "stylesheet", href: "./build/entry.css" - }), _react["default"].createElement(_reactFrameComponent.FrameContextConsumer, null, function (frameContext) { - return _react["default"].createElement(_componentRenderer["default"], { + }), /*#__PURE__*/_react["default"].createElement(_reactFrameComponent.FrameContextConsumer, null, function (frameContext) { + return /*#__PURE__*/_react["default"].createElement(_componentRenderer["default"], { frameContext: frameContext }, component); - })), _react["default"].createElement("div", { + })), /*#__PURE__*/_react["default"].createElement("div", { className: "bd__button" - }, _react["default"].createElement("a", { + }, /*#__PURE__*/_react["default"].createElement("a", { href: "#", onClick: this.toggleEditor - }, "Modify Example Code")), showEditor ? _react["default"].createElement("div", { + }, "Modify Example Code")), showEditor ? /*#__PURE__*/_react["default"].createElement("div", { className: "field" - }, _react["default"].createElement(_reactAce["default"], { + }, /*#__PURE__*/_react["default"].createElement(_reactAce["default"], { style: { width: '100%', height: '200px', @@ -208,12 +178,8 @@ function (_React$Component) { })) : ''); } }]); - return Wrapper; }(_react["default"].Component); - -var _default = function _default(props) { - return _react["default"].createElement(Wrapper, props); -}; - -exports["default"] = _default; \ No newline at end of file +var _default = exports["default"] = function _default(props) { + return /*#__PURE__*/_react["default"].createElement(Wrapper, props); +}; \ No newline at end of file diff --git a/lib/vue-wrapper.js b/lib/vue-wrapper.js index 9dafc38d..14523b48 100644 --- a/lib/vue-wrapper.js +++ b/lib/vue-wrapper.js @@ -4,14 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; - var _vue2AceEditor = _interopRequireDefault(require("vue2-ace-editor")); - var _underscore = _interopRequireDefault(require("underscore")); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } - -var _default = { +var _default = exports["default"] = { template: "\n
\n \n

Modify Example Code

\n
\n \n \n
\n
\n ", props: { defaultCode: String @@ -35,24 +31,19 @@ var _default = { }, editorInit: function editorInit() { require('brace/ext/language_tools'); //language extension prerequsite... - - require('brace/mode/jsx'); //language - - require('brace/theme/monokai'); }, renderComponent: function renderComponent(originalCode) { var code = originalCode || this.code; var json = {}; - try { if (code && code.length && code[0] === '{') { json = eval('(' + code + ')'); } - } catch (e) {// simply example is not a json object + } catch (e) { + // simply example is not a json object } - try { json.components = vueComponents; json.template = json.template || code; @@ -80,5 +71,4 @@ var _default = { this.debounceRenderComponent(newCode); } } -}; -exports["default"] = _default; \ No newline at end of file +}; \ No newline at end of file diff --git a/package.json b/package.json index afc85264..4a77f01b 100644 --- a/package.json +++ b/package.json @@ -15,37 +15,37 @@ "license": "MIT", "dependencies": { "brace": "^0.11.1", - "react-ace": "^9.5.0", - "react-docgen": "^5.4.0", - "react-frame-component": "^5.2.1", - "typescript": "^4.5.4", - "underscore": "^1.13.2", - "vue-docgen-api": "^3.26.0", + "react-ace": "^10.1.0", + "react-docgen": "^5.4.3", + "react-frame-component": "^5.2.6", + "typescript": "^4.9.5", + "underscore": "^1.13.6", + "vue-docgen-api": "^4.56.4", "vue2-ace-editor": "^0.0.15" }, "peerDependencies": { - "react": "^17.0.2", - "react-dom": "^17.0.2" + "react": "^18.2.0", + "react-dom": "^18.2.0" }, "devDependencies": { - "@babel/cli": "^7.16.8", - "@babel/core": "^7.16.7", - "@babel/preset-env": "^7.16.8", - "@babel/preset-react": "^7.16.7", - "@commitlint/cli": "^16.0.2", - "@commitlint/config-conventional": "^16.0.0", + "@babel/cli": "^7.21.0", + "@babel/core": "^7.21.0", + "@babel/preset-env": "^7.20.2", + "@babel/preset-react": "^7.18.6", + "@commitlint/cli": "^17.4.4", + "@commitlint/config-conventional": "^17.4.4", "@semantic-release/git": "^10.0.1", "@vue/component-compiler-utils": "^3.3.0", - "browser-sync": "^2.27.7", - "bulma": "^0.9.3", - "chai": "^4.3.4", - "eslint": "^8.7.0", + "browser-sync": "^2.27.12", + "bulma": "^0.9.4", + "chai": "^4.3.7", + "eslint": "^8.34.0", "eslint-config-airbnb": "^19.0.4", "eslint-config-airbnb-base": "^15.0.0", - "eslint-plugin-import": "^2.25.4", - "eslint-plugin-jsx-a11y": "^6.5.1", - "eslint-plugin-react": "^7.28.0", - "eslint-plugin-vue": "^8.3.0", + "eslint-plugin-import": "^2.27.5", + "eslint-plugin-jsx-a11y": "^6.7.1", + "eslint-plugin-react": "^7.32.2", + "eslint-plugin-vue": "^9.9.0", "gulp": "^4.0.2", "gulp-autoprefixer": "^8.0.0", "gulp-babel": "^8.0.0", @@ -53,11 +53,11 @@ "gulp-rename": "^2.0.0", "gulp-sass": "^5.1.0", "gulp-uglify": "^3.0.2", - "husky": "^7.0.4", - "jsdoc": "^3.6.7", - "mocha": "^9.1.4", - "sass": "^1.48.0", - "semantic-release": "^18.0.1" + "husky": "^8.0.3", + "jsdoc": "^4.0.2", + "mocha": "^10.2.0", + "sass": "^1.58.3", + "semantic-release": "^19.0.5" }, "husky": { "hooks": { diff --git a/publish.js b/publish.js index 0a4338d9..89ea6ca2 100644 --- a/publish.js +++ b/publish.js @@ -6,7 +6,7 @@ var fs = require('jsdoc/fs') var helper = require('jsdoc/util/templateHelper') var logger = require('jsdoc/util/logger') var path = require('jsdoc/path') -var taffy = require('@jsdoc/salty').taffy +const { taffy } = require('@jsdoc/salty'); var template = require('jsdoc/template') var util = require('util') const { getParser } = require('jsdoc/util/markdown') @@ -369,7 +369,7 @@ function buildMemberNav(items, itemHeading, itemsSeen, linktoFn) { if (itemsNav !== '') { var heading = itemHeading if (subCategoryName) { - heading = heading + ' / ' + subCategoryName + heading = heading === 'Globals' ? subCategoryName : heading + ' / ' + subCategoryName } nav += '

' + heading + '

' } @@ -405,6 +405,7 @@ function buildGroupNav (members, title) { nav += buildMemberNav(members.events || [], 'Events', seen, linkto) nav += buildMemberNav(members.mixins || [], 'Mixins', seen, linkto) nav += buildMemberNav(members.components || [], 'Components', seen, linkto) + nav += buildMemberNav(members.globals || [], 'Globals', seen, linkto) if (members.globals && members.globals.length) { globalNav = '' @@ -693,7 +694,7 @@ exports.publish = function(taffyData, opts, tutorials) { members.tutorials = tutorials.children } view.tutorials = members.tutorials - members.components = helper.find(data, {kind: 'class', component: {isUndefined: false}}) + members.components = helper.find(data, { type: 'component' }) members.classes = helper.find(data, {kind: 'class', component: {isUndefined: true}}) // output pretty-printed source files by default diff --git a/src/react-wrapper.jsx b/src/react-wrapper.jsx index 652596f2..a64ab584 100644 --- a/src/react-wrapper.jsx +++ b/src/react-wrapper.jsx @@ -69,12 +69,13 @@ class Wrapper extends React.Component { const padding = 5 // buffer for any unstyled margins if ( this.iframeRef.current - && this.iframeRef.current.node.contentDocument - && this.iframeRef.current.node.contentDocument.body.offsetHeight !== 0 - && this.iframeRef.current.node.contentDocument.body.offsetHeight !== (height - padding) + && this.iframeRef.current.contentDocument + && this.iframeRef.current.contentDocument.body + && this.iframeRef.current.contentDocument.body.offsetHeight !== 0 + && this.iframeRef.current.contentDocument.body.offsetHeight !== (height - padding) ) { this.setState({ - height: this.iframeRef.current.node.contentDocument.body.offsetHeight + padding, + height: this.iframeRef.current.contentDocument.body.offsetHeight + padding, }) } } diff --git a/tmpl/head.tmpl b/tmpl/head.tmpl index 1e787c1e..2a5bebdd 100644 --- a/tmpl/head.tmpl +++ b/tmpl/head.tmpl @@ -9,7 +9,7 @@ - +