@abi-software/simulationvuer 3.0.12 → 3.0.14
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.
- package/README.md +11 -10
- package/dist/index.html +10 -6
- package/dist/simulationvuer.js +11793 -11663
- package/dist/simulationvuer.umd.cjs +103 -103
- package/dist/style.css +1 -1
- package/package.json +19 -7
- package/public/index.html +10 -6
- package/src/App.vue +161 -46
- package/src/assets/_variables.scss +13 -11
- package/src/assets/styles.scss +2 -2
- package/src/components/SimulationVuer.vue +228 -113
- package/src/components/SimulationVuerInput.vue +2 -1
- package/src/components/common.js +19 -8
- package/src/components/index.js +2 -4
- package/src/components/json.js +144 -73
- package/src/main.js +2 -1
- package/vite.config.js +11 -6
- package/vuese-generator.js +77 -80
package/vuese-generator.js
CHANGED
|
@@ -5,133 +5,130 @@
|
|
|
5
5
|
* To watch components changes for Vitepress on Dev Mode
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import path from 'path'
|
|
10
|
-
import chokidar from 'chokidar'
|
|
11
|
-
import { parseSource } from 'vue-docgen-api'
|
|
12
|
-
import { Render } from '@vuese/markdown-render'
|
|
8
|
+
import { Render } from "@vuese/markdown-render";
|
|
13
9
|
|
|
14
|
-
|
|
10
|
+
import chokidar from "chokidar";
|
|
11
|
+
import fs from "node:fs";
|
|
12
|
+
import path from "node:path";
|
|
13
|
+
import { parseSource } from "vue-docgen-api";
|
|
15
14
|
|
|
16
|
-
const
|
|
17
|
-
const components = ['SimulationVuer.vue']
|
|
18
|
-
const outputDir = 'docs/components'
|
|
15
|
+
const watchMode = process.argv.find((argv) => argv === "watch");
|
|
19
16
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
const componentsDir = "src/components";
|
|
18
|
+
const components = ["SimulationVuer.vue"];
|
|
19
|
+
const outputDir = "docs/components";
|
|
20
|
+
|
|
21
|
+
async function generateMarkdown(file) {
|
|
22
|
+
const fileWithPath = `${componentsDir}/${file}`;
|
|
23
|
+
const fileContent = fs.readFileSync(fileWithPath, "utf-8");
|
|
23
24
|
|
|
24
25
|
try {
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
26
|
+
const result = await parseSource(fileContent, fileWithPath);
|
|
27
|
+
const {
|
|
28
|
+
displayName: name,
|
|
29
|
+
description: desc,
|
|
30
|
+
props,
|
|
31
|
+
events,
|
|
32
|
+
methods,
|
|
33
|
+
} = result;
|
|
34
|
+
|
|
35
|
+
// transform props to vuese styles
|
|
36
|
+
const parseResult = {
|
|
37
|
+
name: name,
|
|
38
|
+
componentDesc: {
|
|
39
|
+
default: [desc],
|
|
40
|
+
},
|
|
41
|
+
props: transformData(props),
|
|
42
|
+
events: transformData(events),
|
|
43
|
+
methods: transformData(methods),
|
|
44
|
+
};
|
|
45
|
+
parseResult.name = "SimulationVuer"; // Because there has another name prop in component
|
|
46
|
+
const r = new Render(parseResult);
|
|
47
|
+
const markdownResult = r.renderMarkdown();
|
|
48
|
+
const markdownContent = markdownResult.content;
|
|
49
|
+
const componentName = path.basename(fileWithPath, ".vue");
|
|
50
|
+
|
|
51
|
+
if (!fs.existsSync(outputDir)) {
|
|
52
|
+
fs.mkdirSync(outputDir);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await fs.promises.writeFile(
|
|
56
|
+
`${outputDir}/${componentName}.md`,
|
|
57
|
+
markdownContent,
|
|
58
|
+
);
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
console.log(`Markdown file for ${componentName} is generated!`)
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
})
|
|
65
|
-
} catch(e) {
|
|
66
|
-
console.error(e)
|
|
60
|
+
console.log(`Markdown file for ${componentName} is generated!`);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
// log parse or write errors so the developer knows something went wrong
|
|
63
|
+
console.error(`Failed to generate markdown for ${file}:`, e);
|
|
67
64
|
}
|
|
68
65
|
}
|
|
69
66
|
|
|
70
67
|
function transformData(data = []) {
|
|
71
68
|
function capitalise(str) {
|
|
72
|
-
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
69
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
data.forEach((prop) => {
|
|
76
|
-
prop.name = prop.name
|
|
77
|
-
|
|
78
73
|
if (prop.description) {
|
|
79
|
-
prop.describe = [prop.description.replaceAll(
|
|
74
|
+
prop.describe = [prop.description.replaceAll("\n", " ")];
|
|
80
75
|
}
|
|
81
76
|
|
|
82
77
|
if (prop.type) {
|
|
83
78
|
// Handle multiple types separated by '|'
|
|
84
79
|
// Convert to array to avoid markdown table issues
|
|
85
|
-
if (prop.type.name.indexOf(
|
|
86
|
-
prop.type = prop.type.name
|
|
80
|
+
if (prop.type.name.indexOf("|") !== -1) {
|
|
81
|
+
prop.type = prop.type.name
|
|
82
|
+
.split("|")
|
|
83
|
+
.map((item) => capitalise(item.trim()));
|
|
87
84
|
} else {
|
|
88
|
-
prop.type = capitalise(prop.type.name)
|
|
85
|
+
prop.type = capitalise(prop.type.name);
|
|
89
86
|
}
|
|
90
87
|
}
|
|
91
88
|
|
|
92
89
|
if (prop.defaultValue) {
|
|
93
|
-
prop.default = prop.defaultValue.value.replaceAll(
|
|
90
|
+
prop.default = prop.defaultValue.value.replaceAll("\n", " ");
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
// events
|
|
97
94
|
if (prop.properties) {
|
|
98
|
-
prop.argumentsDesc = []
|
|
95
|
+
prop.argumentsDesc = [];
|
|
99
96
|
prop.properties.forEach((param) => {
|
|
100
|
-
const argName = param.name || param.description
|
|
101
|
-
prop.argumentsDesc.push(argName)
|
|
102
|
-
})
|
|
97
|
+
const argName = param.name || param.description;
|
|
98
|
+
prop.argumentsDesc.push(argName);
|
|
99
|
+
});
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
// methods
|
|
106
103
|
if (prop.params) {
|
|
107
|
-
prop.argumentsDesc = []
|
|
104
|
+
prop.argumentsDesc = [];
|
|
108
105
|
prop.params.forEach((param) => {
|
|
109
|
-
const argName = param.description || param.name
|
|
110
|
-
prop.argumentsDesc.push(argName)
|
|
111
|
-
})
|
|
106
|
+
const argName = param.description || param.name;
|
|
107
|
+
prop.argumentsDesc.push(argName);
|
|
108
|
+
});
|
|
112
109
|
}
|
|
113
|
-
})
|
|
110
|
+
});
|
|
114
111
|
if (!data.length) {
|
|
115
|
-
return null
|
|
112
|
+
return null;
|
|
116
113
|
}
|
|
117
|
-
return data
|
|
114
|
+
return data;
|
|
118
115
|
}
|
|
119
116
|
|
|
120
117
|
// To generate markdown files - one time
|
|
121
118
|
components.forEach((component) => {
|
|
122
|
-
console.log(`Write markdown file for ${component} on first load.`)
|
|
123
|
-
generateMarkdown(component)
|
|
124
|
-
})
|
|
119
|
+
console.log(`Write markdown file for ${component} on first load.`);
|
|
120
|
+
generateMarkdown(component);
|
|
121
|
+
});
|
|
125
122
|
|
|
126
123
|
// To watch component changes and generate markdown files
|
|
127
124
|
if (watchMode) {
|
|
128
125
|
const watcher = chokidar.watch(components, {
|
|
129
126
|
cwd: componentsDir,
|
|
130
127
|
ignoreInitial: true,
|
|
131
|
-
})
|
|
128
|
+
});
|
|
132
129
|
|
|
133
|
-
watcher.on(
|
|
134
|
-
console.log(`The component ${file} has changed!`)
|
|
135
|
-
generateMarkdown(file)
|
|
136
|
-
})
|
|
130
|
+
watcher.on("change", (file) => {
|
|
131
|
+
console.log(`The component ${file} has changed!`);
|
|
132
|
+
generateMarkdown(file);
|
|
133
|
+
});
|
|
137
134
|
}
|