1 | 'use strict';
|
2 |
|
3 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
|
4 |
|
5 | var React = _interopDefault(require('react'));
|
6 | var bubleJsxOnly = require('buble-jsx-only');
|
7 | var mdx = _interopDefault(require('@mdx-js/mdx'));
|
8 | var react = require('@mdx-js/react');
|
9 |
|
10 | function _defineProperty(obj, key, value) {
|
11 | if (key in obj) {
|
12 | Object.defineProperty(obj, key, {
|
13 | value: value,
|
14 | enumerable: true,
|
15 | configurable: true,
|
16 | writable: true
|
17 | });
|
18 | } else {
|
19 | obj[key] = value;
|
20 | }
|
21 |
|
22 | return obj;
|
23 | }
|
24 |
|
25 | function ownKeys(object, enumerableOnly) {
|
26 | var keys = Object.keys(object);
|
27 |
|
28 | if (Object.getOwnPropertySymbols) {
|
29 | var symbols = Object.getOwnPropertySymbols(object);
|
30 | if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
31 | return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
32 | });
|
33 | keys.push.apply(keys, symbols);
|
34 | }
|
35 |
|
36 | return keys;
|
37 | }
|
38 |
|
39 | function _objectSpread2(target) {
|
40 | for (var i = 1; i < arguments.length; i++) {
|
41 | var source = arguments[i] != null ? arguments[i] : {};
|
42 |
|
43 | if (i % 2) {
|
44 | ownKeys(Object(source), true).forEach(function (key) {
|
45 | _defineProperty(target, key, source[key]);
|
46 | });
|
47 | } else if (Object.getOwnPropertyDescriptors) {
|
48 | Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
49 | } else {
|
50 | ownKeys(Object(source)).forEach(function (key) {
|
51 | Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
52 | });
|
53 | }
|
54 | }
|
55 |
|
56 | return target;
|
57 | }
|
58 |
|
59 | function _setPrototypeOf(o, p) {
|
60 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
61 | o.__proto__ = p;
|
62 | return o;
|
63 | };
|
64 |
|
65 | return _setPrototypeOf(o, p);
|
66 | }
|
67 |
|
68 | function _isNativeReflectConstruct() {
|
69 | if (typeof Reflect === "undefined" || !Reflect.construct) return false;
|
70 | if (Reflect.construct.sham) return false;
|
71 | if (typeof Proxy === "function") return true;
|
72 |
|
73 | try {
|
74 | Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
|
75 | return true;
|
76 | } catch (e) {
|
77 | return false;
|
78 | }
|
79 | }
|
80 |
|
81 | function _construct(Parent, args, Class) {
|
82 | if (_isNativeReflectConstruct()) {
|
83 | _construct = Reflect.construct;
|
84 | } else {
|
85 | _construct = function _construct(Parent, args, Class) {
|
86 | var a = [null];
|
87 | a.push.apply(a, args);
|
88 | var Constructor = Function.bind.apply(Parent, a);
|
89 | var instance = new Constructor();
|
90 | if (Class) _setPrototypeOf(instance, Class.prototype);
|
91 | return instance;
|
92 | };
|
93 | }
|
94 |
|
95 | return _construct.apply(null, arguments);
|
96 | }
|
97 |
|
98 | function _objectWithoutPropertiesLoose(source, excluded) {
|
99 | if (source == null) return {};
|
100 | var target = {};
|
101 | var sourceKeys = Object.keys(source);
|
102 | var key, i;
|
103 |
|
104 | for (i = 0; i < sourceKeys.length; i++) {
|
105 | key = sourceKeys[i];
|
106 | if (excluded.indexOf(key) >= 0) continue;
|
107 | target[key] = source[key];
|
108 | }
|
109 |
|
110 | return target;
|
111 | }
|
112 |
|
113 | function _objectWithoutProperties(source, excluded) {
|
114 | if (source == null) return {};
|
115 |
|
116 | var target = _objectWithoutPropertiesLoose(source, excluded);
|
117 |
|
118 | var key, i;
|
119 |
|
120 | if (Object.getOwnPropertySymbols) {
|
121 | var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
122 |
|
123 | for (i = 0; i < sourceSymbolKeys.length; i++) {
|
124 | key = sourceSymbolKeys[i];
|
125 | if (excluded.indexOf(key) >= 0) continue;
|
126 | if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
127 | target[key] = source[key];
|
128 | }
|
129 | }
|
130 |
|
131 | return target;
|
132 | }
|
133 |
|
134 | function _toConsumableArray(arr) {
|
135 | return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
136 | }
|
137 |
|
138 | function _arrayWithoutHoles(arr) {
|
139 | if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
140 | }
|
141 |
|
142 | function _iterableToArray(iter) {
|
143 | if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
144 | }
|
145 |
|
146 | function _unsupportedIterableToArray(o, minLen) {
|
147 | if (!o) return;
|
148 | if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
149 | var n = Object.prototype.toString.call(o).slice(8, -1);
|
150 | if (n === "Object" && o.constructor) n = o.constructor.name;
|
151 | if (n === "Map" || n === "Set") return Array.from(n);
|
152 | if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
153 | }
|
154 |
|
155 | function _arrayLikeToArray(arr, len) {
|
156 | if (len == null || len > arr.length) len = arr.length;
|
157 |
|
158 | for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
159 |
|
160 | return arr2;
|
161 | }
|
162 |
|
163 | function _nonIterableSpread() {
|
164 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
165 | }
|
166 |
|
167 | var index = (function (_ref) {
|
168 | var _ref$scope = _ref.scope,
|
169 | scope = _ref$scope === void 0 ? {} : _ref$scope,
|
170 | _ref$components = _ref.components,
|
171 | components = _ref$components === void 0 ? {} : _ref$components,
|
172 | _ref$remarkPlugins = _ref.remarkPlugins,
|
173 | remarkPlugins = _ref$remarkPlugins === void 0 ? [] : _ref$remarkPlugins,
|
174 | _ref$rehypePlugins = _ref.rehypePlugins,
|
175 | rehypePlugins = _ref$rehypePlugins === void 0 ? [] : _ref$rehypePlugins,
|
176 | children = _ref.children,
|
177 | props = _objectWithoutProperties(_ref, ["scope", "components", "remarkPlugins", "rehypePlugins", "children"]);
|
178 |
|
179 | var fullScope = _objectSpread2({
|
180 | mdx: react.mdx,
|
181 | MDXProvider: react.MDXProvider,
|
182 | components: components,
|
183 | props: props
|
184 | }, scope);
|
185 |
|
186 | var jsx = mdx.sync(children, {
|
187 | remarkPlugins: remarkPlugins,
|
188 | rehypePlugins: rehypePlugins,
|
189 | skipExport: true
|
190 | }).trim();
|
191 | var code;
|
192 |
|
193 | try {
|
194 | code = bubleJsxOnly.transform(jsx, {
|
195 | objectAssign: 'Object.assign'
|
196 | }).code;
|
197 | } catch (err) {
|
198 | console.error(err);
|
199 | throw err;
|
200 | }
|
201 |
|
202 | var keys = Object.keys(fullScope);
|
203 | var values = Object.values(fullScope);
|
204 |
|
205 | var fn = _construct(Function, ['_fn', 'React'].concat(_toConsumableArray(keys), ["".concat(code, "\n\n return React.createElement(MDXProvider, { components },\n React.createElement(MDXContent, props)\n );")]));
|
206 |
|
207 | return fn.apply(void 0, [{}, React].concat(_toConsumableArray(values)));
|
208 | });
|
209 |
|
210 | module.exports = index;
|