@antv/dumi-theme-antv 0.5.4 → 0.5.5-beta.1

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,101 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/plugin/antVReactTechStack.ts
30
+ var antVReactTechStack_exports = {};
31
+ __export(antVReactTechStack_exports, {
32
+ AntVReactTechStack: () => AntVReactTechStack
33
+ });
34
+ module.exports = __toCommonJS(antVReactTechStack_exports);
35
+ var import_react = __toESM(require("dumi/dist/techStacks/react"));
36
+ var import_fs = __toESM(require("fs"));
37
+ var import_sylvanas = __toESM(require("sylvanas"));
38
+ var import_package = require("../../package.json");
39
+ var AntVReactTechStack = class extends import_react.default {
40
+ generatePreviewerProps(...[props, opts]) {
41
+ var _a;
42
+ props.pkgDependencyList = { ...import_package.devDependencies, ...import_package.dependencies };
43
+ props.jsx ?? (props.jsx = "");
44
+ if (opts.type === "code-block") {
45
+ props.jsx = (opts == null ? void 0 : opts.entryPointCode) ? import_sylvanas.default.parseText(opts.entryPointCode) : "";
46
+ }
47
+ if (opts.type === "external") {
48
+ const locale = (_a = opts.mdAbsPath.match(/[a-z-]+\.([a-z-]+)\.md$/i)) == null ? void 0 : _a[1];
49
+ const mdPath = opts.fileAbsPath.replace(/\.\w+$/, ".md");
50
+ const md = import_fs.default.existsSync(mdPath) ? import_fs.default.readFileSync(mdPath, "utf-8") : "";
51
+ const codePath = opts.fileAbsPath.replace(/\.\w+$/, ".tsx");
52
+ const code = import_fs.default.existsSync(codePath) ? import_fs.default.readFileSync(codePath, "utf-8") : "";
53
+ props.jsx = import_sylvanas.default.parseText(code);
54
+ if (md) {
55
+ const blocks = {};
56
+ const lines = md.split("\n");
57
+ let blockName = "";
58
+ let cacheList = [];
59
+ const getBlockName = (text) => {
60
+ if (text.startsWith("## ")) {
61
+ return text.replace("## ", "").trim();
62
+ }
63
+ if (text.startsWith("```css") || text.startsWith("<style>")) {
64
+ return "style";
65
+ }
66
+ return null;
67
+ };
68
+ const fillBlock = (name, lineList) => {
69
+ if (lineList.length) {
70
+ let fullText;
71
+ if (name === "style") {
72
+ fullText = lineList.join("\n").replace(/<\/?style>/g, "").replace(/```(\s*css)/g, "");
73
+ } else {
74
+ fullText = lineList.slice(1).join("\n");
75
+ }
76
+ blocks[name] = fullText;
77
+ }
78
+ };
79
+ for (let i = 0; i < lines.length; i++) {
80
+ const line = lines[i];
81
+ const nextBlockName = getBlockName(line);
82
+ if (nextBlockName) {
83
+ fillBlock(blockName, cacheList);
84
+ blockName = nextBlockName;
85
+ cacheList = [line];
86
+ } else {
87
+ cacheList.push(line);
88
+ }
89
+ }
90
+ fillBlock(blockName, cacheList);
91
+ props.description = blocks[locale];
92
+ props.style = blocks.style;
93
+ }
94
+ }
95
+ return props;
96
+ }
97
+ };
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ AntVReactTechStack
101
+ });
@@ -34,6 +34,7 @@ __export(plugin_exports, {
34
34
  module.exports = __toCommonJS(plugin_exports);
35
35
  var import_plugin_utils = require("dumi/plugin-utils");
36
36
  var path = __toESM(require("path"));
37
+ var import_antVReactTechStack = require("./antVReactTechStack");
37
38
  var import_examples = require("./examples");
38
39
  var import_rehypeObservable = __toESM(require("./rehypeObservable"));
39
40
  var PAGES_DIR = (0, import_plugin_utils.winPath)(path.join(__dirname, "../pages"));
@@ -135,4 +136,6 @@ export default function ThemeAntVContextWrapper() {
135
136
  return routes;
136
137
  });
137
138
  api.addTmpGenerateWatcherPaths(() => [path.resolve(process.cwd(), "examples")]);
139
+ console.log("api", api);
140
+ api.registerTechStack(() => new import_antVReactTechStack.AntVReactTechStack());
138
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/dumi-theme-antv",
3
- "version": "0.5.4",
3
+ "version": "0.5.5-beta.1",
4
4
  "description": "AntV website theme based on dumi2.",
5
5
  "keywords": [
6
6
  "dumi",
@@ -84,6 +84,7 @@
84
84
  "semver": "^7.6.3",
85
85
  "size-sensor": "^1.0.2",
86
86
  "slick-carousel": "^1.8.1",
87
+ "sylvanas": "^0.6.1",
87
88
  "unified": "^10.1.2",
88
89
  "unist-util-visit": "^4.1.2",
89
90
  "uri-parse": "^1.0.0",
@@ -123,7 +124,8 @@
123
124
  "react-dom": ">=16.9.0"
124
125
  },
125
126
  "publishConfig": {
126
- "access": "public"
127
+ "access": "public",
128
+ "tag": "beta"
127
129
  },
128
130
  "authors": [
129
131
  "dumi",