@ui5/webcomponents-tools 0.0.0-fd6264051 → 0.0.0-ff1549e7b
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/CHANGELOG.md +375 -0
- package/README.md +5 -6
- package/assets-meta.js +1 -0
- package/bin/dev.js +1 -5
- package/components-package/eslint.js +34 -0
- package/components-package/nps.js +87 -58
- package/components-package/postcss.components.js +13 -13
- package/components-package/postcss.themes.js +26 -16
- package/components-package/vite.config.js +13 -0
- package/components-package/wdio.js +401 -369
- package/components-package/wdio.sync.js +10 -2
- package/icons-collection/nps.js +8 -11
- package/lib/copy-and-watch/index.js +24 -1
- package/lib/copy-list/index.js +17 -17
- package/lib/create-icons/index.js +124 -72
- package/lib/create-illustrations/index.js +101 -90
- package/lib/create-new-component/index.js +71 -104
- package/lib/create-new-component/jsFileContentTemplate.js +73 -0
- package/lib/create-new-component/tsFileContentTemplate.js +80 -0
- package/lib/dev-server/dev-server.js +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +52 -0
- package/lib/esm-abs-to-rel/index.js +13 -9
- package/lib/generate-custom-elements-manifest/index.js +327 -0
- package/lib/generate-js-imports/illustrations.js +72 -0
- package/lib/generate-json-imports/i18n.js +38 -31
- package/lib/generate-json-imports/themes.js +31 -24
- package/lib/hbs2lit/src/compiler.js +24 -4
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +85 -22
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
- package/lib/hbs2ui5/index.js +56 -23
- package/lib/i18n/defaults.js +65 -57
- package/lib/i18n/toJSON.js +12 -11
- package/lib/jsdoc/configTypescript.json +29 -0
- package/lib/jsdoc/plugin.js +32 -0
- package/lib/jsdoc/preprocess.js +146 -0
- package/lib/jsdoc/template/publish.js +9 -1
- package/lib/postcss-combine-duplicated-selectors/index.js +178 -0
- package/lib/postcss-css-to-esm/index.js +51 -6
- package/lib/postcss-css-to-json/index.js +12 -1
- package/lib/postcss-p/postcss-p.mjs +14 -0
- package/lib/replace-global-core/index.js +13 -8
- package/lib/scoping/get-all-tags.js +1 -8
- package/lib/scoping/scope-test-pages.js +1 -1
- package/lib/test-runner/test-runner.js +71 -0
- package/package.json +27 -26
- package/components-package/rollup-plugins/empty-module.js +0 -15
- package/components-package/rollup.js +0 -239
- package/lib/documentation/index.js +0 -165
- package/lib/documentation/templates/api-component-since.js +0 -3
- package/lib/documentation/templates/api-css-variables-section.js +0 -24
- package/lib/documentation/templates/api-events-section.js +0 -35
- package/lib/documentation/templates/api-methods-section.js +0 -26
- package/lib/documentation/templates/api-properties-section.js +0 -42
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -39
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/polyfill-placeholder/index.js +0 -5
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "0.0.0-
|
3
|
+
"version": "0.0.0-ff1549e7b",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -21,26 +21,19 @@
|
|
21
21
|
"directory": "packages/tools"
|
22
22
|
},
|
23
23
|
"dependencies": {
|
24
|
-
"@
|
25
|
-
"@
|
26
|
-
"@
|
27
|
-
"@
|
28
|
-
"@
|
29
|
-
"@
|
30
|
-
"@
|
31
|
-
"@
|
32
|
-
"@
|
33
|
-
"@wdio/cli": "^7.12.2",
|
34
|
-
"@wdio/dot-reporter": "^7.10.1",
|
35
|
-
"@wdio/local-runner": "^7.12.2",
|
36
|
-
"@wdio/mocha-framework": "^7.12.2",
|
37
|
-
"@wdio/spec-reporter": "^7.10.1",
|
38
|
-
"@webcomponents/webcomponentsjs": "^2.5.0",
|
24
|
+
"@typescript-eslint/eslint-plugin": "^5.42.1",
|
25
|
+
"@typescript-eslint/parser": "^5.42.1",
|
26
|
+
"@wdio/cli": "^7.19.7",
|
27
|
+
"@wdio/devtools-service": "^7.19.7",
|
28
|
+
"@wdio/dot-reporter": "^7.19.7",
|
29
|
+
"@wdio/local-runner": "^7.19.7",
|
30
|
+
"@wdio/mocha-framework": "^7.19.7",
|
31
|
+
"@wdio/spec-reporter": "^7.19.7",
|
32
|
+
"@wdio/static-server-service": "^7.19.5",
|
39
33
|
"chai": "^4.3.4",
|
40
34
|
"child_process": "^1.0.2",
|
41
35
|
"chokidar": "^3.5.1",
|
42
36
|
"chokidar-cli": "^3.0.0",
|
43
|
-
"cli-color": "^2.0.1",
|
44
37
|
"command-line-args": "^5.1.1",
|
45
38
|
"concurrently": "^6.0.0",
|
46
39
|
"cross-env": "^7.0.3",
|
@@ -50,33 +43,41 @@
|
|
50
43
|
"eslint-config-airbnb-base": "^14.2.1",
|
51
44
|
"eslint-plugin-import": "^2.22.1",
|
52
45
|
"esprima": "^4.0.1",
|
53
|
-
"folder-hash": "^4.0.1",
|
54
46
|
"getopts": "^2.3.0",
|
55
47
|
"glob": "^7.1.6",
|
56
48
|
"glob-parent": "^6.0.2",
|
49
|
+
"globby": "^13.1.1",
|
57
50
|
"handlebars": "^4.7.7",
|
58
51
|
"is-port-reachable": "^3.1.0",
|
59
52
|
"jsdoc": "^3.6.6",
|
60
53
|
"json-beautify": "^1.1.1",
|
61
54
|
"mkdirp": "^1.0.4",
|
55
|
+
"modify-selectors": "^2.0.0",
|
62
56
|
"nps": "^5.10.0",
|
63
57
|
"postcss": "^8.4.5",
|
64
58
|
"postcss-cli": "^9.1.0",
|
65
|
-
"postcss-combine-duplicated-selectors": "^10.0.3",
|
66
59
|
"postcss-import": "^14.0.2",
|
60
|
+
"postcss-selector-parser": "^6.0.10",
|
61
|
+
"prompts": "^2.4.2",
|
67
62
|
"properties-reader": "^2.2.0",
|
68
63
|
"recursive-readdir": "^2.2.2",
|
69
64
|
"resolve": "^1.20.0",
|
70
65
|
"rimraf": "^3.0.2",
|
71
|
-
"rollup": "^2.41.4",
|
72
|
-
"rollup-plugin-filesize": "^9.1.1",
|
73
|
-
"rollup-plugin-livereload": "^2.0.0",
|
74
|
-
"rollup-plugin-terser": "^7.0.2",
|
75
|
-
"serve": "^12.0.0",
|
76
66
|
"slash": "3.0.0",
|
77
|
-
"
|
67
|
+
"vite": "^3.0.4",
|
68
|
+
"wdio-chromedriver-service": "^7.3.2",
|
69
|
+
"zx": "^4.3.0"
|
78
70
|
},
|
79
71
|
"peerDependencies": {
|
80
|
-
"chromedriver": "*"
|
72
|
+
"chromedriver": "*",
|
73
|
+
"typescript": "^4.9.4"
|
74
|
+
},
|
75
|
+
"peerDependenciesMeta": {
|
76
|
+
"typescript": {
|
77
|
+
"optional": true
|
78
|
+
}
|
79
|
+
},
|
80
|
+
"devDependencies": {
|
81
|
+
"yargs": "^17.5.1"
|
81
82
|
}
|
82
83
|
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
const slash = require("slash");
|
2
|
-
|
3
|
-
function emptyModulePlugin({ emptyModules }) {
|
4
|
-
return {
|
5
|
-
name: "ui5-dev-empty-module-plugin",
|
6
|
-
load(id) {
|
7
|
-
if (emptyModules.some(mod => slash(id).includes(mod))) {
|
8
|
-
return `export default ""`;
|
9
|
-
}
|
10
|
-
return null;
|
11
|
-
},
|
12
|
-
};
|
13
|
-
}
|
14
|
-
|
15
|
-
module.exports = emptyModulePlugin;
|
@@ -1,239 +0,0 @@
|
|
1
|
-
const process = require("process");
|
2
|
-
const fs = require("fs");
|
3
|
-
const os = require("os");
|
4
|
-
const { babel } = require("@rollup/plugin-babel");
|
5
|
-
const { nodeResolve } = require("@rollup/plugin-node-resolve");
|
6
|
-
const url = require("@rollup/plugin-url");
|
7
|
-
const { terser } = require("rollup-plugin-terser");
|
8
|
-
const json = require("@rollup/plugin-json");
|
9
|
-
const replace = require("@rollup/plugin-replace");
|
10
|
-
const commonjs = require("@rollup/plugin-commonjs");
|
11
|
-
const colors = require("cli-color");
|
12
|
-
const filesize = require("rollup-plugin-filesize");
|
13
|
-
const livereload = require("rollup-plugin-livereload");
|
14
|
-
const emptyModulePlugin = require("./rollup-plugins/empty-module.js");
|
15
|
-
|
16
|
-
const packageFile = JSON.parse(fs.readFileSync("./package.json"));
|
17
|
-
const packageName = packageFile.name;
|
18
|
-
const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
|
19
|
-
|
20
|
-
const warningsToSkip = [{
|
21
|
-
warningCode: "THIS_IS_UNDEFINED",
|
22
|
-
filePath: /.+zxing.+/,
|
23
|
-
}];
|
24
|
-
|
25
|
-
function ui5DevImportCheckerPlugin() {
|
26
|
-
return {
|
27
|
-
name: "ui5-dev-import-checker-plugin",
|
28
|
-
transform(code, file) {
|
29
|
-
const re = new RegExp(`^import.*"${packageName}/`);
|
30
|
-
if (re.test(code)) {
|
31
|
-
throw new Error(`illegal import in ${file}`);
|
32
|
-
}
|
33
|
-
},
|
34
|
-
};
|
35
|
-
}
|
36
|
-
|
37
|
-
function onwarn(warning, warn) {
|
38
|
-
// Skip warning for known false positives that will otherwise polute the log
|
39
|
-
let skip = warningsToSkip.find(warningToSkip => {
|
40
|
-
let loc, file;
|
41
|
-
return warning.code === warningToSkip.warningCode
|
42
|
-
&& (loc = warning.loc)
|
43
|
-
&& (file = loc.file)
|
44
|
-
&& file.match(warningToSkip.filePath);
|
45
|
-
});
|
46
|
-
if (skip) {
|
47
|
-
return;
|
48
|
-
}
|
49
|
-
|
50
|
-
// warn everything else
|
51
|
-
warn( warning );
|
52
|
-
}
|
53
|
-
|
54
|
-
const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
|
55
|
-
function ui5DevReadyMessagePlugin() {
|
56
|
-
return {
|
57
|
-
name: "ui5-dev-message-ready-plugin",
|
58
|
-
writeBundle: (assets, bundle) => {
|
59
|
-
if (reportedForPackages.has(packageName)) {
|
60
|
-
return;
|
61
|
-
}
|
62
|
-
console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
|
63
|
-
|
64
|
-
if (fs.existsSync(".port")) {
|
65
|
-
const port = `${fs.readFileSync(".port")}`;
|
66
|
-
if (port) {
|
67
|
-
console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
|
68
|
-
}
|
69
|
-
}
|
70
|
-
reportedForPackages.add(packageName);
|
71
|
-
},
|
72
|
-
};
|
73
|
-
}
|
74
|
-
|
75
|
-
const getPlugins = ({ transpile }) => {
|
76
|
-
const plugins = [];
|
77
|
-
|
78
|
-
if (process.env.DEV) {
|
79
|
-
plugins.push(replace({
|
80
|
-
values: {
|
81
|
-
'const DEV_MODE = false': 'const DEV_MODE = true',
|
82
|
-
},
|
83
|
-
preventAssignment: false,
|
84
|
-
}));
|
85
|
-
}
|
86
|
-
|
87
|
-
if (process.env.DEV && !process.env.ENABLE_CLDR) {
|
88
|
-
// Empty the CLDR assets file for better performance during development
|
89
|
-
plugins.push(emptyModulePlugin({
|
90
|
-
emptyModules: [
|
91
|
-
"localization/dist/Assets.js",
|
92
|
-
],
|
93
|
-
}));
|
94
|
-
}
|
95
|
-
|
96
|
-
if (!process.env.DEV) {
|
97
|
-
plugins.push(filesize(
|
98
|
-
{
|
99
|
-
reporter(options, bundle, {
|
100
|
-
minSize, gzipSize, brotliSize, bundleSize,
|
101
|
-
fileName,
|
102
|
-
// "showBeforeSizes: release"
|
103
|
-
lastVersion,
|
104
|
-
// "showBeforeSizes: "release" or "showBeforeSizes": "build"
|
105
|
-
bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
|
106
|
-
}) {
|
107
|
-
// If a promise is returned, it will be awaited before rendering.
|
108
|
-
return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
|
109
|
-
},
|
110
|
-
},
|
111
|
-
|
112
|
-
));
|
113
|
-
}
|
114
|
-
|
115
|
-
const publicPath = DEPLOY_PUBLIC_PATH;
|
116
|
-
|
117
|
-
plugins.push(ui5DevImportCheckerPlugin());
|
118
|
-
|
119
|
-
if (!transpile) {
|
120
|
-
plugins.push(json({
|
121
|
-
include: [
|
122
|
-
/.*assets\/.*\.json/,
|
123
|
-
],
|
124
|
-
namedExports: false,
|
125
|
-
}));
|
126
|
-
}
|
127
|
-
|
128
|
-
if (transpile) {
|
129
|
-
plugins.push(url({
|
130
|
-
limit: 0,
|
131
|
-
include: [
|
132
|
-
/.*assets\/.*\.json/,
|
133
|
-
],
|
134
|
-
emitFiles: true,
|
135
|
-
fileName: "[name].[hash][extname]",
|
136
|
-
publicPath,
|
137
|
-
}));
|
138
|
-
}
|
139
|
-
|
140
|
-
if (transpile) {
|
141
|
-
plugins.push(commonjs());
|
142
|
-
plugins.push(babel({
|
143
|
-
presets: ["@babel/preset-env"],
|
144
|
-
exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
|
145
|
-
sourcemap: false,
|
146
|
-
babelHelpers: "bundled",
|
147
|
-
}));
|
148
|
-
}
|
149
|
-
|
150
|
-
plugins.push(nodeResolve());
|
151
|
-
|
152
|
-
if (!process.env.DEV) {
|
153
|
-
plugins.push(terser({
|
154
|
-
numWorkers: 1,
|
155
|
-
}));
|
156
|
-
}
|
157
|
-
|
158
|
-
const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
|
159
|
-
if (es6DevMain && os.platform() !== "win32") {
|
160
|
-
plugins.push(livereload({
|
161
|
-
watch: [
|
162
|
-
"dist/resources/bundle.esm.js",
|
163
|
-
"dist/**/*.html",
|
164
|
-
"dist/**/*.json",
|
165
|
-
],
|
166
|
-
}));
|
167
|
-
}
|
168
|
-
|
169
|
-
if (process.env.DEV) {
|
170
|
-
plugins.push(ui5DevReadyMessagePlugin());
|
171
|
-
}
|
172
|
-
|
173
|
-
return plugins;
|
174
|
-
};
|
175
|
-
|
176
|
-
const getES6Config = (input = "bundle.esm.js") => {
|
177
|
-
return [{
|
178
|
-
input,
|
179
|
-
output: {
|
180
|
-
dir: "dist/resources",
|
181
|
-
format: "esm",
|
182
|
-
sourcemap: true,
|
183
|
-
},
|
184
|
-
moduleContext: id => {
|
185
|
-
if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
|
186
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
187
|
-
return "window";
|
188
|
-
}
|
189
|
-
},
|
190
|
-
watch: {
|
191
|
-
clearScreen: false,
|
192
|
-
},
|
193
|
-
plugins: getPlugins({ transpile: false }),
|
194
|
-
onwarn: onwarn,
|
195
|
-
}];
|
196
|
-
};
|
197
|
-
|
198
|
-
const getES5Config = (input = "bundle.es5.js") => {
|
199
|
-
return [{
|
200
|
-
input,
|
201
|
-
output: {
|
202
|
-
dir: "dist/resources",
|
203
|
-
format: "iife",
|
204
|
-
inlineDynamicImports: true,
|
205
|
-
name: "sap-ui-webcomponents-bundle",
|
206
|
-
extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
|
207
|
-
sourcemap: true,
|
208
|
-
},
|
209
|
-
moduleContext: id => {
|
210
|
-
if (id.includes("url-search-params-polyfill")) {
|
211
|
-
// suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
|
212
|
-
return "window";
|
213
|
-
}
|
214
|
-
},
|
215
|
-
watch: {
|
216
|
-
clearScreen: false,
|
217
|
-
},
|
218
|
-
plugins: getPlugins({ transpile: true }),
|
219
|
-
onwarn: onwarn,
|
220
|
-
}];
|
221
|
-
};
|
222
|
-
|
223
|
-
let config = getES6Config();
|
224
|
-
|
225
|
-
if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
|
226
|
-
config = config.concat(getES5Config());
|
227
|
-
}
|
228
|
-
|
229
|
-
if (process.env.SCOPE) {
|
230
|
-
if (fs.existsSync("bundle.scoped.esm.js")) {
|
231
|
-
config = config.concat(getES6Config("bundle.scoped.esm.js"));
|
232
|
-
|
233
|
-
if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
|
234
|
-
config = config.concat(getES5Config("bundle.scoped.es5.js"));
|
235
|
-
}
|
236
|
-
}
|
237
|
-
}
|
238
|
-
|
239
|
-
module.exports = config;
|
@@ -1,165 +0,0 @@
|
|
1
|
-
const cssVariables = {};
|
2
|
-
const template = require('./templates/template').template;
|
3
|
-
const sinceTemplate = require('./templates/api-component-since').template;
|
4
|
-
const propertiesTemplate = require('./templates/api-properties-section').template;
|
5
|
-
const slotsTemplate = require('./templates/api-slots-section').template;
|
6
|
-
const eventsTemplate = require('./templates/api-events-section').template;
|
7
|
-
const methodsTemplate = require('./templates/api-methods-section').template;
|
8
|
-
const cssVariablesTemplate = require('./templates/api-css-variables-section').template;
|
9
|
-
const Handlebars = require('handlebars/dist/handlebars.min.js');
|
10
|
-
const fs = require('fs');
|
11
|
-
const path = require('path');
|
12
|
-
const mkdirp = require('mkdirp');
|
13
|
-
const beautify = require("json-beautify");
|
14
|
-
|
15
|
-
|
16
|
-
const apiJSONPath = path.normalize(process.argv[2]);
|
17
|
-
const api = JSON.parse(fs.readFileSync(apiJSONPath));
|
18
|
-
|
19
|
-
fs.writeFileSync(apiJSONPath, beautify(api, null, 2, 100));
|
20
|
-
|
21
|
-
const entries = api['symbols'];
|
22
|
-
const compiledHandlebars = Handlebars.compile(template);
|
23
|
-
const compiledSinceTemplate = Handlebars.compile(sinceTemplate);
|
24
|
-
const linkMatcher = /{@link(\s)(\w+)\s*}/gi;
|
25
|
-
const sinceMarker = "<!--since_tag_marker-->";
|
26
|
-
|
27
|
-
const getComponentByName = name => {
|
28
|
-
return entries.find(element => {
|
29
|
-
return element.basename === name;
|
30
|
-
})
|
31
|
-
};
|
32
|
-
|
33
|
-
const getCSSVarsByName = name => {
|
34
|
-
return cssVariables[name] || [];
|
35
|
-
};
|
36
|
-
|
37
|
-
const capitalize = str => {
|
38
|
-
return str.replace(/^./, str => str.toUpperCase());
|
39
|
-
};
|
40
|
-
|
41
|
-
Handlebars.registerHelper('toLowerCase', function (str) {
|
42
|
-
return str ? str.toLowerCase() : "";
|
43
|
-
});
|
44
|
-
|
45
|
-
Handlebars.registerHelper('toKebabCase', function (str) {
|
46
|
-
const kebab = str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
47
|
-
return kebab !== str ? kebab : undefined;
|
48
|
-
});
|
49
|
-
|
50
|
-
Handlebars.registerHelper('checkEven', function (iIndex) {
|
51
|
-
return (iIndex % 2 === 0) ? "api-table-roll-even" : "api-table-roll-odd";
|
52
|
-
});
|
53
|
-
|
54
|
-
Handlebars.registerPartial('properties', propertiesTemplate);
|
55
|
-
Handlebars.registerPartial('slots', slotsTemplate);
|
56
|
-
Handlebars.registerPartial('events', eventsTemplate);
|
57
|
-
Handlebars.registerPartial('methods', methodsTemplate);
|
58
|
-
Handlebars.registerPartial('cssVariables', cssVariablesTemplate);
|
59
|
-
|
60
|
-
mkdirp.sync(`dist/test-resources/api`);
|
61
|
-
|
62
|
-
let entriesAPI = [];
|
63
|
-
|
64
|
-
const appendCSSVarsAPI = entry => {
|
65
|
-
entry.cssVariables = getCSSVarsByName(entry.basename);
|
66
|
-
return entry;
|
67
|
-
}
|
68
|
-
|
69
|
-
const componentHasEntityItem = (component, entity, name) => {
|
70
|
-
return component[entity].some(x => x && x.name === name);
|
71
|
-
};
|
72
|
-
const removeEmpty = arr => arr.filter(x => x);
|
73
|
-
|
74
|
-
const calculateAPI = component => {
|
75
|
-
if (entriesAPI.indexOf(component.basename) !== -1) {
|
76
|
-
return component;
|
77
|
-
}
|
78
|
-
const entities = ["properties", "slots", "events", "methods", "cssVariables"];
|
79
|
-
|
80
|
-
// Initialize all entities with [] if necessary, and remove undefined things, and only leave public things
|
81
|
-
entities.forEach(entity => {
|
82
|
-
component[entity] = removeEmpty(component[entity] || []).filter(x => x.visibility === "public");
|
83
|
-
});
|
84
|
-
|
85
|
-
component = appendCSSVarsAPI(component);
|
86
|
-
|
87
|
-
let parent = getComponentByName(component.extends);
|
88
|
-
if (parent) {
|
89
|
-
let parentComponent = calculateAPI(parent);
|
90
|
-
entities.forEach(entity => {
|
91
|
-
parentComponent[entity].forEach( x => {
|
92
|
-
if (!componentHasEntityItem(component, entity, x.name)) {
|
93
|
-
component[entity].push(x);
|
94
|
-
}
|
95
|
-
});
|
96
|
-
});
|
97
|
-
}
|
98
|
-
|
99
|
-
entriesAPI.push(component.basename);
|
100
|
-
|
101
|
-
return component;
|
102
|
-
};
|
103
|
-
|
104
|
-
const appendAdditionalEntriesAPI = entry => {
|
105
|
-
if (entry.appenddocs) {
|
106
|
-
const additionalEntries = entry.appenddocs.split(" ");
|
107
|
-
entry.additionalDocs = [];
|
108
|
-
|
109
|
-
additionalEntries.forEach(entryName => {
|
110
|
-
let additionalEntry = getComponentByName(entryName);
|
111
|
-
additionalEntry = calculateAPI(additionalEntry);
|
112
|
-
entry.additionalDocs.push(additionalEntry);
|
113
|
-
});
|
114
|
-
}
|
115
|
-
|
116
|
-
return entry;
|
117
|
-
}
|
118
|
-
|
119
|
-
const generateSamplePage = entry => {
|
120
|
-
let content = "";
|
121
|
-
|
122
|
-
try {
|
123
|
-
content = fs.readFileSync(`dist/test-resources/samples/${capitalize(entry.basename)}.sample.html`, 'utf8');
|
124
|
-
} catch (err) { }
|
125
|
-
|
126
|
-
if (content) {
|
127
|
-
entry.slots.forEach(slotData => {
|
128
|
-
if (!slotData.type.startsWith("Node") && !slotData.type.startsWith("HTMLElement")) { // interface -> don't show in documentation
|
129
|
-
slotData.type = "HTMLElement" + (slotData.type.endsWith("[]") ? "[]" : "");
|
130
|
-
}
|
131
|
-
});
|
132
|
-
const APIReference = compiledHandlebars(entry).replace(/\[\]/g, " [0..n]");
|
133
|
-
const EntitySince = compiledSinceTemplate(entry).replace(/\[\]/g, " [0..n]");
|
134
|
-
|
135
|
-
content = content.replace('<!-- JSDoc marker -->', APIReference);
|
136
|
-
content = content.replace(sinceMarker, EntitySince);
|
137
|
-
|
138
|
-
content = content.replace(linkMatcher, match => {
|
139
|
-
const component = linkMatcher.exec(match)[2];
|
140
|
-
|
141
|
-
// reset the regex
|
142
|
-
linkMatcher.lastIndex = 0;
|
143
|
-
|
144
|
-
return `<a href="#" onclick="redirect(event, '${component}')">${component}</a>`;
|
145
|
-
});
|
146
|
-
|
147
|
-
fs.writeFile(`dist/test-resources/api/${entry.basename}.sample.html`, content, (err) => {
|
148
|
-
// console.log(err);
|
149
|
-
});
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
const generateComponentAPI = entry => {
|
154
|
-
// (1) calculate the API
|
155
|
-
entry = calculateAPI(entry);
|
156
|
-
|
157
|
-
// (2) append additional API for composition components - List -> ListIems, TabContainer -> Tabs, Table -> TableRow/Column/Cell
|
158
|
-
entry = appendAdditionalEntriesAPI(entry);
|
159
|
-
|
160
|
-
// (3) generate sample page
|
161
|
-
generateSamplePage(entry);
|
162
|
-
}
|
163
|
-
|
164
|
-
entries.forEach(generateComponentAPI);
|
165
|
-
entriesAPI = [];
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
template: `
|
3
|
-
{{#if cssVariables}}
|
4
|
-
<h3 class="comment-api-title" >CSS variables</h3>
|
5
|
-
<p class="small-space-top">You can use the following CSS varialbes to change the component styling.</p>
|
6
|
-
|
7
|
-
<div class="small-space-top api-table">
|
8
|
-
<div class="head api-table-header-roll">
|
9
|
-
<div class="cell api-table-header-cell">Name</div>
|
10
|
-
<div class="cell api-table-header-cell">Description</div>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
{{#each cssVariables}}
|
14
|
-
<div class="row {{checkEven @index}}">
|
15
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
|
16
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">
|
17
|
-
{{{this.description}}}
|
18
|
-
</div>
|
19
|
-
</div>
|
20
|
-
{{/each}}
|
21
|
-
|
22
|
-
</div>
|
23
|
-
{{/if}}`
|
24
|
-
};
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
template: `
|
3
|
-
{{#if events}}
|
4
|
-
<h3 class="comment-api-title space-top">Events</h3>
|
5
|
-
<p class="small-space-top" >This Web Component fires semantic events upon user interaction. You can bind to these events with the standard DOM APIs, such as <code>addEventListener</code>. </p>
|
6
|
-
|
7
|
-
<div class="small-space-top api-table">
|
8
|
-
<div class="head api-table-header-roll">
|
9
|
-
<div class="cell api-table-header-cell">Name</div>
|
10
|
-
<div class="cell api-table-header-cell">Description</div>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
{{#each events}}
|
14
|
-
<div class="row {{checkEven @index}}">
|
15
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
|
16
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">
|
17
|
-
{{{this.description}}}
|
18
|
-
{{#if this.since}}
|
19
|
-
<div class="api-table-content-cell-bold api-table-content-cell-since">since v{{{this.since}}}</div>
|
20
|
-
{{/if}}
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
|
24
|
-
{{#each this.parameters}}
|
25
|
-
<tr class="api-table-event-param">
|
26
|
-
<div class="api-table-content-event-params-wrapper">
|
27
|
-
<div class="cell api-table-param-name api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
|
28
|
-
<div class="cell api-table-event-param-cell api-table-content-cell api-table-content-cell-description"><strong class="bold" >type:</strong> {{this.type}} <br/> <strong class="api-table-event-description bold">description:</strong> {{{this.description}}}</div>
|
29
|
-
</div>
|
30
|
-
</tr>
|
31
|
-
{{/each}}
|
32
|
-
{{/each}}
|
33
|
-
</div>
|
34
|
-
{{/if}}`
|
35
|
-
};
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
template: `
|
3
|
-
{{#if methods}}
|
4
|
-
<h3 class="comment-api-title space-top">Methods</h3>
|
5
|
-
<p class="small-space-top" >This Web Component exposes public methods. You can invoke them directly on the Web Component instance.</p>
|
6
|
-
|
7
|
-
<div class="small-space-top api-table">
|
8
|
-
<div class="head api-table-header-roll">
|
9
|
-
<div class="cell api-table-header-cell">Name</div>
|
10
|
-
<div class="cell api-table-header-cell">Description</div>
|
11
|
-
</div>
|
12
|
-
|
13
|
-
{{#each methods}}
|
14
|
-
<div class="row {{checkEven @index}}">
|
15
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
|
16
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">{{{this.description}}}</div>
|
17
|
-
</div>
|
18
|
-
|
19
|
-
{{#each this.parameters}}
|
20
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold api-table-param-name">{{this.name}}</div>
|
21
|
-
<div class="cell api-table-event-param-cell api-table-content-cell api-table-content-cell-description"><strong class="bold" >type:</strong> {{this.type}} <br/> <strong class="api-table-event-description bold">description:</strong> {{{this.description}}}</div>
|
22
|
-
{{/each}}
|
23
|
-
{{/each}}
|
24
|
-
</div>
|
25
|
-
{{/if}}`
|
26
|
-
};
|
@@ -1,42 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
template: `
|
3
|
-
{{#if properties}}
|
4
|
-
<h3 class="comment-api-title" >Properties/Attributes</h3>
|
5
|
-
<p class="small-space-top" >You can use both properties and attributes with the same effect. The name of each attribute is listed below the name of the property, if different.</p>
|
6
|
-
|
7
|
-
<div class="small-space-top api-table">
|
8
|
-
<div class="head api-table-header-roll">
|
9
|
-
<div class="cell api-table-header-cell">Name</div>
|
10
|
-
<div class="cell api-table-header-cell">Type</div>
|
11
|
-
<div class="cell api-table-header-cell">Default Value</div>
|
12
|
-
<div class="cell api-table-header-cell">Description</div>
|
13
|
-
</div>
|
14
|
-
|
15
|
-
{{#each properties}}
|
16
|
-
<div class="row {{checkEven @index}}">
|
17
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold">
|
18
|
-
{{this.name}}
|
19
|
-
{{#if this.readonly}}
|
20
|
-
(readonly)
|
21
|
-
{{/if}}
|
22
|
-
<br>
|
23
|
-
{{#if (toKebabCase this.name)}}
|
24
|
-
{{#unless this.noattribute}}
|
25
|
-
<code>{{toKebabCase this.name}}</code>
|
26
|
-
{{/unless}}
|
27
|
-
{{/if}}
|
28
|
-
</div>
|
29
|
-
<div class="cell api-table-content-cell">{{this.type}}</div>
|
30
|
-
<div class="cell api-table-content-cell">{{this.defaultValue}}</div>
|
31
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">
|
32
|
-
{{{this.description}}}
|
33
|
-
{{#if this.since}}
|
34
|
-
<div class="api-table-content-cell-bold api-table-content-cell-since">since v{{{this.since}}}</div>
|
35
|
-
{{/if}}
|
36
|
-
</div>
|
37
|
-
</div>
|
38
|
-
{{/each}}
|
39
|
-
|
40
|
-
</div>
|
41
|
-
{{/if}}`
|
42
|
-
};
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module.exports = {
|
2
|
-
template: `
|
3
|
-
{{#if slots}}
|
4
|
-
<h3 class="comment-api-title space-top" >Slots</h3>
|
5
|
-
<p class="small-space-top" >
|
6
|
-
This Element provides slot(s). This means it can display its child nodes.<br>
|
7
|
-
Unless targeting the default slot, use the <code>slot</code> attribute to define the destination slot for each child.<br>
|
8
|
-
Text, along with HTML Elements with no <code>slot</code> attribute, goes the the <code>default</code> slot.
|
9
|
-
</p>
|
10
|
-
|
11
|
-
<div class="small-space-top api-table">
|
12
|
-
<div class="head api-table-header-roll">
|
13
|
-
<div class="cell api-table-header-cell">Slot</div>
|
14
|
-
<div class="cell api-table-header-cell">Type</div>
|
15
|
-
<div class="cell api-table-header-cell">Description</div>
|
16
|
-
</div>
|
17
|
-
|
18
|
-
{{#each slots}}
|
19
|
-
<div class="row {{checkEven @index}}">
|
20
|
-
<div class="cell api-table-content-cell api-table-content-cell-bold">{{this.name}}</div>
|
21
|
-
<div class="cell api-table-content-cell">{{this.type}}</div>
|
22
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">{{{this.description}}}</div>
|
23
|
-
</div>
|
24
|
-
{{/each}}
|
25
|
-
|
26
|
-
</div>
|
27
|
-
{{/if}}`
|
28
|
-
};
|