@ui5/webcomponents-tools 0.0.0-ec448881d → 0.0.0-ee3bbe46b

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.
Files changed (44) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +5 -6
  3. package/bin/dev.js +1 -5
  4. package/components-package/eslint.js +28 -0
  5. package/components-package/nps.js +71 -42
  6. package/components-package/vite.config.js +12 -0
  7. package/components-package/wdio.js +28 -4
  8. package/components-package/wdio.sync.js +1 -1
  9. package/icons-collection/nps.js +2 -1
  10. package/lib/copy-list/index.js +2 -2
  11. package/lib/create-icons/index.js +21 -2
  12. package/lib/create-new-component/index.js +5 -5
  13. package/lib/dev-server/dev-server.js +66 -0
  14. package/lib/dev-server/virtual-index-html-plugin.js +53 -0
  15. package/lib/generate-custom-elements-manifest/index.js +373 -0
  16. package/lib/generate-js-imports/illustrations.js +72 -0
  17. package/lib/generate-json-imports/themes.js +3 -3
  18. package/lib/hbs2lit/src/compiler.js +8 -0
  19. package/lib/hbs2lit/src/litVisitor2.js +46 -8
  20. package/lib/i18n/defaults.js +9 -0
  21. package/lib/jsdoc/configTypescript.json +29 -0
  22. package/lib/jsdoc/plugin.js +32 -0
  23. package/lib/jsdoc/preprocess.js +147 -0
  24. package/lib/jsdoc/template/publish.js +9 -1
  25. package/lib/postcss-css-to-esm/index.js +13 -1
  26. package/lib/postcss-css-to-json/index.js +12 -1
  27. package/lib/postcss-p/postcss-p.mjs +3 -0
  28. package/lib/scoping/get-all-tags.js +1 -8
  29. package/lib/scoping/scope-test-pages.js +1 -1
  30. package/lib/test-runner/test-runner.js +63 -0
  31. package/package.json +15 -16
  32. package/components-package/rollup-plugins/empty-module.js +0 -15
  33. package/components-package/rollup.js +0 -150
  34. package/lib/documentation/index.js +0 -168
  35. package/lib/documentation/templates/api-component-since.js +0 -3
  36. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  37. package/lib/documentation/templates/api-events-section.js +0 -35
  38. package/lib/documentation/templates/api-methods-section.js +0 -26
  39. package/lib/documentation/templates/api-properties-section.js +0 -42
  40. package/lib/documentation/templates/api-slots-section.js +0 -28
  41. package/lib/documentation/templates/template.js +0 -39
  42. package/lib/serve/index.js +0 -46
  43. package/lib/serve/serve.json +0 -3
  44. package/package-lock.json +0 -48
@@ -1,168 +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').promises;
11
- const path = require('path');
12
- const beautify = require("json-beautify");
13
-
14
- const generate = async () => {
15
-
16
- const apiJSONPath = path.normalize(process.argv[2]);
17
- const api = JSON.parse(await fs.readFile(apiJSONPath));
18
-
19
- await fs.writeFile(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
- await fs.mkdir(`dist/test-resources/api`, { recursive: true });
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 = async entry => {
120
- let content = "";
121
-
122
- try {
123
- content = await fs.readFile(`dist/test-resources/samples/${capitalize(entry.basename)}.sample.html`, 'utf8');
124
- } catch (err) {
125
- }
126
-
127
- if (content) {
128
- entry.slots.forEach(slotData => {
129
- if (!slotData.type.startsWith("Node") && !slotData.type.startsWith("HTMLElement")) { // interface -> don't show in documentation
130
- slotData.type = "HTMLElement" + (slotData.type.endsWith("[]") ? "[]" : "");
131
- }
132
- });
133
- const APIReference = compiledHandlebars(entry).replace(/\[\]/g, " [0..n]");
134
- const EntitySince = compiledSinceTemplate(entry).replace(/\[\]/g, " [0..n]");
135
-
136
- content = content.replace('<!-- JSDoc marker -->', APIReference);
137
- content = content.replace(sinceMarker, EntitySince);
138
-
139
- content = content.replace(linkMatcher, match => {
140
- const component = linkMatcher.exec(match)[2];
141
-
142
- // reset the regex
143
- linkMatcher.lastIndex = 0;
144
-
145
- return `<a href="#" onclick="redirect(event, '${component}')">${component}</a>`;
146
- });
147
-
148
- return fs.writeFile(`dist/test-resources/api/${entry.basename}.sample.html`, content);
149
- }
150
- }
151
-
152
- const generateComponentAPI = entry => {
153
- // (1) calculate the API
154
- entry = calculateAPI(entry);
155
-
156
- // (2) append additional API for composition components - List -> ListIems, TabContainer -> Tabs, Table -> TableRow/Column/Cell
157
- entry = appendAdditionalEntriesAPI(entry);
158
-
159
- // (3) generate sample page
160
- return generateSamplePage(entry);
161
- }
162
-
163
- return Promise.all(entries.map(generateComponentAPI));
164
- };
165
-
166
- generate().then(() => {
167
- console.log("Documentation generated.");
168
- });
@@ -1,3 +0,0 @@
1
- module.exports = {
2
- template: `{{#if this.since}}v{{this.since}}{{/if}}`
3
- };
@@ -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
- };
@@ -1,39 +0,0 @@
1
- module.exports = {
2
- template: `
3
- <div class="page-container">
4
- <div class="api-container">
5
- <section class="component-description">
6
- {{{description}}}
7
- <section class="component-api space-top">
8
- {{> properties this}}
9
- {{> slots this}}
10
- {{> events this}}
11
- {{> methods this}}
12
- {{> cssVariables this}}
13
- </section>
14
- </section>
15
- </div>
16
- </div>
17
- {{#each additionalDocs}}
18
- <div class="api-container appended-doc">
19
- <h1>{{this.basename}}</h1>
20
- <section class="component-description">
21
- {{{this.description}}}
22
- <section class="component-api space-top">
23
- {{> properties this}}
24
- {{> slots this}}
25
- {{> events this}}
26
- {{> methods this}}
27
- {{> cssVariables this}}
28
- </section>
29
- </section>
30
- </div>
31
- {{/each}}
32
- <footer class="footer-wrapper">
33
- <div class="footer-links">
34
- <a class="separator" href="https://www.sap.com/about/legal/privacy.html" target="_blank">Privacy Policy</a>
35
- <a href="https://www.sap.com/about/legal/impressum.html" target="_blank">Legal</a>
36
- </div>
37
- <img src="../../../assets/images/sap-logo-svg.svg" alt="Sap Logo" />
38
- </footer>`
39
- };
@@ -1,46 +0,0 @@
1
- const fs = require("fs");
2
- const path = require("path");
3
- const commandLineArgs = require("command-line-args");
4
- const { exec } = require("child_process");
5
- const colors = require("cli-color");
6
- const isPortReachable = require("is-port-reachable");
7
-
8
- const options = commandLineArgs([
9
- { name: "port", type: Number },
10
- { name: "portStep", type: Number },
11
- { name: "packageName", type: String },
12
- { name: "dir", type: String },
13
- { name: "config", type: String },
14
- ]);
15
- const serveConfig = path.join(__dirname, `serve.json`);
16
-
17
- const requestPort = async () => {
18
- const serveProcess = (await gen.next()).value;
19
- serveProcess.stdout.on('data', data => {
20
- const matches = data.match(/Accepting connections at .*?:(\d+)/);
21
- if (matches) {
22
- console.log(colors.yellow(`Reserved port ${matches[1]} for the ${options.packageName} package.`));
23
- fs.writeFileSync(".port", matches[1]);
24
- }
25
- });
26
- };
27
-
28
- async function* serverGenerator(callback, port = 8080, step = 1) {
29
- while (true) {
30
- const portInUse = await isPortReachable(port, { host: "127.0.0.1" });
31
- if (!portInUse) {
32
- const command = `serve --config "${serveConfig}" --no-port-switching --no-clipboard -l ${port} ${options.dir}`;
33
- console.log(colors.yellow(`Executing: ${command}`));
34
- const serveProcess = exec(command, (err) => {
35
- console.log(colors.yellow(`Port ${port} already in use.`));
36
- callback();
37
- });
38
- yield serveProcess;
39
- }
40
- port += step;
41
- }
42
- }
43
-
44
- const gen = serverGenerator(requestPort, options.port, options.portStep);
45
-
46
- requestPort();
@@ -1,3 +0,0 @@
1
- {
2
- "cleanUrls": false
3
- }
package/package-lock.json DELETED
@@ -1,48 +0,0 @@
1
- {
2
- "name": "@ui5/webcomponents-tools",
3
- "version": "1.0.0-rc.8",
4
- "lockfileVersion": 1,
5
- "requires": true,
6
- "dependencies": {
7
- "balanced-match": {
8
- "version": "1.0.0",
9
- "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
10
- "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
11
- "dev": true
12
- },
13
- "brace-expansion": {
14
- "version": "1.1.11",
15
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
16
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
17
- "dev": true,
18
- "requires": {
19
- "balanced-match": "^1.0.0",
20
- "concat-map": "0.0.1"
21
- }
22
- },
23
- "concat-map": {
24
- "version": "0.0.1",
25
- "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
26
- "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
27
- "dev": true
28
- },
29
- "minimatch": {
30
- "version": "3.0.4",
31
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
32
- "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
33
- "dev": true,
34
- "requires": {
35
- "brace-expansion": "^1.1.7"
36
- }
37
- },
38
- "recursive-readdir": {
39
- "version": "2.2.2",
40
- "resolved": "https://registry.npmjs.org/recursive-readdir/-/recursive-readdir-2.2.2.tgz",
41
- "integrity": "sha512-nRCcW9Sj7NuZwa2XvH9co8NPeXUBhZP7CRKJtU+cS6PW9FpCIFoI5ib0NT1ZrbNuPoRy0ylyCaUL8Gih4LSyFg==",
42
- "dev": true,
43
- "requires": {
44
- "minimatch": "3.0.4"
45
- }
46
- }
47
- }
48
- }