dumi 2.3.0-alpha.8 → 2.3.0-alpha.9

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.
@@ -12,6 +12,6 @@ export var evalCode = function evalCode(code, scope) {
12
12
  var scopeValues = scopeKeys.map(function (key) {
13
13
  return scope[key];
14
14
  });
15
- var importReg = /import.*from.*;/g;
15
+ var importReg = /import[\S\s]*?from.*;/g;
16
16
  return _construct(Function, scopeKeys.concat([code.replace(importReg, '').replace('export default', 'return').trim()])).apply(void 0, _toConsumableArray(scopeValues));
17
17
  };
@@ -135,7 +135,7 @@ export const texts = {{{texts}}};`,
135
135
  }
136
136
  function emitScope(opts, ret) {
137
137
  const { demos } = ret.meta;
138
- const importReg = /import(?!(\stype)).*from.*;/g;
138
+ const importReg = /import(?!(\stype|\s'))[\s\S]*?from.*;/g;
139
139
  return import_plugin_utils.Mustache.render(
140
140
  `{{#renderImport}}
141
141
  {{{.}}}
@@ -160,9 +160,9 @@ export const scopes = {
160
160
  const fileImports = file.value.match(importReg) || [];
161
161
  fileImports.forEach((item) => {
162
162
  var _a;
163
- const scope = item.replace(/import(.*)from.*;/, "$1").trim();
164
- const dep = item.replace(/import.*from(.*);/, "$1").trim();
165
- const namedReg = /.*\{(.*)}/g;
163
+ const scope = item.replace(/import([\s\S]*?)from.*;/, "$1").trim();
164
+ const dep = item.replace(/import[\s\S]*?from(.*);/, "$1").trim();
165
+ const namedReg = /.*\{([\s\S]*?)}/g;
166
166
  const namedScope = namedReg.test(scope) ? scope.replace(namedReg, "$1").split(",").map((item2) => item2.trim()).filter(Boolean) : [];
167
167
  const defaultReg = /(?:(?![,{]).)*/;
168
168
  const defaultScope = (_a = scope.match(defaultReg)) == null ? void 0 : _a[0].trim();
@@ -198,8 +198,8 @@ export const scopes = {
198
198
  if (filename.endsWith(".tsx")) {
199
199
  const imports = file.value.match(importReg) || [];
200
200
  const scopes = imports.reduce((acc, item) => {
201
- const scope = item.replace(/import(.*)from.*;/, "$1").trim();
202
- const scopeList = scope.replace(/[{}]/g, "").trim();
201
+ const scope = item.replace(/import([\s\S]*?)from.*;/, "$1").trim();
202
+ const scopeList = scope.replace(/[{}]/g, "").trim().replace(/,$/g, "").replace(/\S+\sas\s(.*?)/g, "$1");
203
203
  return [...acc, scopeList];
204
204
  }, []);
205
205
  demoScopes.push(...scopes);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.3.0-alpha.8",
3
+ "version": "2.3.0-alpha.9",
4
4
  "description": "📖 Documentation Generator of React Component",
5
5
  "keywords": [
6
6
  "generator",