dumi 2.0.0-rc.6 → 2.0.0-rc.8

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.
@@ -0,0 +1 @@
1
+ (function(){var e={226:function(e){var n=Object.defineProperty;var t=Object.getOwnPropertyDescriptor;var r=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var __export=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:true})};var __copyProps=(e,o,i,c)=>{if(o&&typeof o==="object"||typeof o==="function"){for(let s of r(o))if(!a.call(e,s)&&s!==i)n(e,s,{get:()=>o[s],enumerable:!(c=t(o,s))||c.enumerable})}return e};var __toCommonJS=e=>__copyProps(n({},"__esModule",{value:true}),e);var o={};__export(o,{default:()=>analytics_default});e.exports=__toCommonJS(o);var analytics_default=e=>{const n=process.env.GA_KEY;const t=process.env.GA_V2_KEY;const enableBy=e=>e.config.analytics||n;e.describe({key:"analytics",config:{schema(e){return e.alternatives().try(e.object({baidu:e.string(),ga:e.string(),ga_v2:e.string()}),e.boolean().invalid(true))},onChange:e.ConfigChangeType.reload},enableBy:enableBy});const baiduTpl=e=>`\n (function() {\n var hm = document.createElement('script');\n hm.src = '//hm.baidu.com/hm.js?${e}';\n var s = document.getElementsByTagName('script')[0];\n s.parentNode.insertBefore(hm, s);\n })();\n `;const gaTpl=e=>`\n (function(){\n if (!location.port) {\n (function (i, s, o, g, r, a, m) {\n i['GoogleAnalyticsObject'] = r;\n i[r] = i[r] || function () {\n (i[r].q = i[r].q || []).push(arguments)\n }, i[r].l = 1 * new Date();\n a = s.createElement(o),\n m = s.getElementsByTagName(o)[0];\n a.async = 1;\n a.src = g;\n m.parentNode.insertBefore(a, m)\n })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');\n ga('create', '${e}', 'auto');\n ga('send', 'pageview');\n }\n })();\n `;const gaV2Tpl=e=>`\n window.dataLayer = window.dataLayer || [];\n function gtag(){dataLayer.push(arguments);}\n gtag('js', new Date());\n gtag('config', '${e}');\n `.trim();e.addHTMLHeadScripts((()=>{const r=e.config.analytics||{};const{baidu:a,ga:o=n,ga_v2:i=t}=r;const c=[];if(a){c.push({content:"var _hmt = _hmt || [];"})}if(e.env!=="development"){if(a){c.push({content:baiduTpl(a)})}if(o){c.push({content:gaTpl(o)})}if(i){c.push({async:true,src:`//www.googletagmanager.com/gtag/js?id=${i}`},{content:gaV2Tpl(i)})}}return c.filter(Boolean)}))};0&&0}};var n={};function __nccwpck_require__(t){var r=n[t];if(r!==undefined){return r.exports}var a=n[t]={exports:{}};var o=true;try{e[t](a,a.exports,__nccwpck_require__);o=false}finally{if(o)delete n[t]}return a.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(226);module.exports=t})();
@@ -0,0 +1 @@
1
+ {"name":"@umijs/plugins","version":"4.0.30","authors":["chencheng <sorrycc@gmail.com> (https://github.com/sorrycc)"],"license":"MIT","_lastModified":"2022-11-13T07:05:33.094Z"}
@@ -118,7 +118,7 @@ var derivative_default = (api) => {
118
118
  }
119
119
  }
120
120
  });
121
- api.registerPlugins([require.resolve("@umijs/plugins/dist/analytics")]);
121
+ api.registerPlugins([require.resolve("../../compiled/@umijs/plugins")]);
122
122
  };
123
123
  // Annotate the CommonJS export names for ESM import in node:
124
124
  0 && (module.exports = {
@@ -44,10 +44,10 @@ function localizeUmiRoute(route, locales) {
44
44
  route.absPath = route.path !== "/" ? `/${route.path}` : route.path;
45
45
  }
46
46
  }
47
- function flatRoute(route) {
48
- if (route.parentId !== "DocLayout") {
49
- route.parentId = "DocLayout";
50
- route.path = route.path === "*" ? route.path.toLowerCase() : route.absPath.slice(1).toLowerCase();
47
+ function flatRoute(route, docLayoutId) {
48
+ if (route.parentId !== docLayoutId) {
49
+ route.parentId = docLayoutId;
50
+ route.path = route.path === "*" ? route.path : route.absPath.slice(1);
51
51
  }
52
52
  }
53
53
  function getClientPageFile(file, cwd) {
@@ -121,8 +121,6 @@ var routes_default = (api) => {
121
121
  }
122
122
  Object.entries(pages).forEach(([, route]) => {
123
123
  route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(api.config.conventionRoutes.base, route.file));
124
- flatRoute(route);
125
- localizeUmiRoute(route, api.config.locales);
126
124
  routes[route.id] = route;
127
125
  });
128
126
  docDirs.map(normalizeDocDir).forEach(({ type, dir }) => {
@@ -133,14 +131,12 @@ var routes_default = (api) => {
133
131
  });
134
132
  Object.entries(dirRoutes).forEach(([key, route]) => {
135
133
  route.id = `${dir}/${key}`;
136
- flatRoute(route);
137
134
  if (type) {
138
135
  const pluralType = (0, import_pluralize.plural)(type);
139
136
  route.path = `${pluralType}/${route.path}`.replace(/\/+$/, "/");
140
137
  route.absPath = `/${route.path}`;
141
138
  }
142
139
  route.file = (0, import_plugin_utils.winPath)(import_path.default.resolve(base, route.file));
143
- localizeUmiRoute(route, api.config.locales);
144
140
  routes[route.id] = route;
145
141
  });
146
142
  });
@@ -148,7 +144,7 @@ var routes_default = (api) => {
148
144
  const base = import_path.default.join(api.cwd, dir);
149
145
  const atomFiles = import_plugin_utils.glob.sync("{*,*/index,*/index.*,*/README,*/README.*}.md", { cwd: base });
150
146
  atomFiles.forEach((file) => {
151
- const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/").toLowerCase();
147
+ const routePath = (0, import_plugin_utils.winPath)(import_path.default.join((0, import_pluralize.plural)(type), file)).replace(/(\/index|\/README)?\.md$/, "").replace(/\./g, "/");
152
148
  const routeId = (0, import_utils.createRouteId)(file);
153
149
  routes[routeId] = {
154
150
  id: routeId,
@@ -157,9 +153,19 @@ var routes_default = (api) => {
157
153
  parentId: docLayoutId,
158
154
  file: (0, import_plugin_utils.winPath)(import_path.default.resolve(base, file))
159
155
  };
160
- localizeUmiRoute(routes[routeId], api.config.locales);
161
156
  });
162
157
  });
158
+ Object.values(routes).forEach((route) => {
159
+ if (route.path !== encodeURI(route.path)) {
160
+ throw new Error(`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
161
+ at ${route.file}`);
162
+ } else if (!route.isLayout) {
163
+ flatRoute(route, docLayoutId);
164
+ localizeUmiRoute(route, api.config.locales);
165
+ route.path = route.path.toLowerCase();
166
+ route.absPath = route.absPath.toLowerCase();
167
+ }
168
+ });
163
169
  if (Object.values(pages).every((route) => route.path !== "*")) {
164
170
  routes["404"] = {
165
171
  id: "404",
@@ -176,12 +182,6 @@ var routes_default = (api) => {
176
182
  parentId: demoLayoutId,
177
183
  file: getClientPageFile("client/pages/Demo", api.cwd)
178
184
  };
179
- Object.values(routes).forEach((route) => {
180
- if (route.path !== encodeURI(route.path)) {
181
- throw new Error(`Invalid route path: ${route.path}, please rename it with only alphanumeric, dash and slash.
182
- at ${route.file}`);
183
- }
184
- });
185
185
  return routes;
186
186
  });
187
187
  api.addLayouts(() => {
@@ -30,10 +30,12 @@ var import_plugin_utils = require("umi/plugin-utils");
30
30
  function getComponentMapFromDir(globExp, dir) {
31
31
  return import_plugin_utils.glob.sync(globExp, { cwd: dir }).reduce((ret, file) => {
32
32
  const specifier = import_path.default.basename(file.replace(/(\/index)?\.[a-z]+$/, ""));
33
- ret[specifier] = {
34
- specifier,
35
- source: (0, import_plugin_utils.winPath)(import_path.default.join(dir, file))
36
- };
33
+ if (/^[A-Z\d]/.test(specifier)) {
34
+ ret[specifier] = {
35
+ specifier,
36
+ source: (0, import_plugin_utils.winPath)(import_path.default.join(dir, file))
37
+ };
38
+ }
37
39
  return ret;
38
40
  }, {});
39
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dumi",
3
- "version": "2.0.0-rc.6",
3
+ "version": "2.0.0-rc.8",
4
4
  "description": "Framework for developing UI components",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -59,7 +59,6 @@
59
59
  "@types/mdast": "^3.0.10",
60
60
  "@umijs/bundler-utils": "^4.0.30",
61
61
  "@umijs/core": "^4.0.30",
62
- "@umijs/plugins": "^4.0.30",
63
62
  "codesandbox": "^2.2.3",
64
63
  "deepmerge": "^4.2.2",
65
64
  "dumi-afx-deps": "^1.0.0-alpha.1",
@@ -118,6 +117,7 @@
118
117
  "@types/react-copy-to-clipboard": "^5.0.4",
119
118
  "@types/react-helmet": "^6.1.5",
120
119
  "@umijs/lint": "^4.0.30",
120
+ "@umijs/plugins": "^4.0.30",
121
121
  "eslint": "^8.20.0",
122
122
  "father": "^4.1.0",
123
123
  "husky": "^8.0.1",