@ui5/webcomponents-tools 0.0.0-b053ad005 → 0.0.0-b132dd7b9
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 +1899 -0
- package/README.md +6 -9
- package/assets-meta.js +13 -8
- package/bin/dev.js +1 -5
- package/components-package/eslint.js +66 -2
- package/components-package/nps.js +130 -72
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -26
- package/components-package/vite.config.js +9 -0
- package/components-package/wdio.js +77 -15
- package/icons-collection/nps.js +13 -14
- package/lib/amd-to-es6/index.js +102 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/custom-elements-manifest.config.mjs +530 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/schema-internal.json +1422 -0
- package/lib/cem/schema.json +1098 -0
- package/lib/cem/types-internal.d.ts +808 -0
- package/lib/cem/types.d.ts +736 -0
- package/lib/cem/utils.mjs +423 -0
- package/lib/cem/validate.js +67 -0
- package/lib/copy-and-watch/index.js +24 -1
- package/lib/copy-list/index.js +17 -17
- package/lib/create-icons/index.js +127 -72
- package/lib/create-illustrations/index.js +153 -66
- package/lib/create-new-component/Component.js +74 -0
- package/lib/create-new-component/ComponentTemplate.js +12 -0
- package/lib/create-new-component/index.js +60 -101
- package/lib/css-processors/css-processor-components.mjs +78 -0
- package/lib/css-processors/css-processor-themes.mjs +74 -0
- package/lib/css-processors/scope-variables.mjs +49 -0
- package/lib/css-processors/shared.mjs +56 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +66 -0
- package/lib/dev-server/virtual-index-html-plugin.js +56 -0
- package/lib/generate-js-imports/illustrations.js +86 -0
- package/lib/generate-json-imports/i18n.js +58 -67
- package/lib/generate-json-imports/themes.js +36 -46
- 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 +39 -6
- package/lib/hbs2ui5/index.js +57 -24
- package/lib/i18n/defaults.js +66 -57
- package/lib/i18n/toJSON.js +12 -11
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
- package/lib/scoping/get-all-tags.js +11 -11
- package/lib/scoping/lint-src.js +8 -7
- package/lib/scoping/missing-dependencies.js +65 -0
- package/lib/scoping/report-tags-usage.js +28 -0
- package/lib/scoping/scope-test-pages.js +2 -1
- package/lib/test-runner/test-runner.js +71 -0
- package/package.json +36 -32
- package/tsconfig.json +18 -0
- package/components-package/rollup-plugins/empty-module.js +0 -15
- package/components-package/rollup.js +0 -237
- package/components-package/wdio.sync.js +0 -344
- 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 -40
- package/lib/documentation/templates/api-slots-section.js +0 -28
- package/lib/documentation/templates/template.js +0 -38
- package/lib/esm-abs-to-rel/index.js +0 -54
- package/lib/hash/config.js +0 -10
- package/lib/hash/generate.js +0 -19
- package/lib/hash/upToDate.js +0 -31
- package/lib/jsdoc/config.json +0 -29
- package/lib/jsdoc/plugin.js +0 -2427
- package/lib/jsdoc/template/publish.js +0 -4101
- package/lib/polyfill-placeholder/index.js +0 -5
- package/lib/postcss-css-to-esm/index.js +0 -45
- package/lib/postcss-css-to-json/index.js +0 -36
- package/lib/postcss-new-files/index.js +0 -36
- package/lib/replace-global-core/index.js +0 -20
- package/lib/serve/index.js +0 -46
- package/lib/serve/serve.json +0 -3
- package/package-lock.json +0 -48
@@ -1,344 +0,0 @@
|
|
1
|
-
exports.config = {
|
2
|
-
//
|
3
|
-
// ====================
|
4
|
-
// Runner Configuration
|
5
|
-
// ====================
|
6
|
-
//
|
7
|
-
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
|
8
|
-
// on a remote machine).
|
9
|
-
runner: 'local',
|
10
|
-
|
11
|
-
//
|
12
|
-
// ==================
|
13
|
-
// Specify Test Files
|
14
|
-
// ==================
|
15
|
-
// Define which test specs should run. The pattern is relative to the directory
|
16
|
-
// from which `wdio` was called. Notice that, if you are calling `wdio` from an
|
17
|
-
// NPM script (see https://docs.npmjs.com/cli/run-script) then the current working
|
18
|
-
// directory is where your package.json resides, so `wdio` will be called from there.
|
19
|
-
//
|
20
|
-
specs: [
|
21
|
-
'./test/specs/**/*.js'
|
22
|
-
],
|
23
|
-
// Patterns to exclude.
|
24
|
-
exclude: [
|
25
|
-
// 'path/to/excluded/files'
|
26
|
-
],
|
27
|
-
//
|
28
|
-
// ============
|
29
|
-
// Capabilities
|
30
|
-
// ============
|
31
|
-
// Define your capabilities here. WebdriverIO can run multiple capabilities at the same
|
32
|
-
// time. Depending on the number of capabilities, WebdriverIO launches several test
|
33
|
-
// sessions. Within your capabilities you can overwrite the spec and exclude options in
|
34
|
-
// order to group specific specs to a specific capability.
|
35
|
-
//
|
36
|
-
// First, you can define how many instances should be started at the same time. Let's
|
37
|
-
// say you have 3 different capabilities (Chrome, Firefox, and Safari) and you have
|
38
|
-
// set maxInstances to 1; wdio will spawn 3 processes. Therefore, if you have 10 spec
|
39
|
-
// files and you set maxInstances to 10, all spec files will get tested at the same time
|
40
|
-
// and 30 processes will get spawned. The property handles how many capabilities
|
41
|
-
// from the same test should run tests.
|
42
|
-
//
|
43
|
-
maxInstances: 10,
|
44
|
-
//
|
45
|
-
// If you have trouble getting all important capabilities together, check out the
|
46
|
-
// Sauce Labs platform configurator - a great tool to configure your capabilities:
|
47
|
-
// https://docs.saucelabs.com/reference/platforms-configurator
|
48
|
-
//
|
49
|
-
capabilities: [{
|
50
|
-
// maxInstances can get overwritten per capability. So if you have an in-house Selenium
|
51
|
-
// grid with only 5 firefox instances available you can make sure that not more than
|
52
|
-
// 5 instances get started at a time.
|
53
|
-
maxInstances: process.env.TRAVIS ? 1 : 5,
|
54
|
-
//
|
55
|
-
browserName: 'chrome',
|
56
|
-
'goog:chromeOptions': {
|
57
|
-
// to run chrome headless the following flags are required
|
58
|
-
// (see https://developers.google.com/web/updates/2017/04/headless-chrome)
|
59
|
-
args: ['--headless', '--disable-gpu'],
|
60
|
-
// args: ['--disable-gpu'],
|
61
|
-
}
|
62
|
-
}],
|
63
|
-
//
|
64
|
-
// port to find chromedriver
|
65
|
-
port: 9515, // default
|
66
|
-
// ===================
|
67
|
-
// Test Configurations
|
68
|
-
// ===================
|
69
|
-
// Define all options that are relevant for the WebdriverIO instance here
|
70
|
-
//
|
71
|
-
// Level of logging verbosity: trace | debug | info | warn | error
|
72
|
-
logLevel: 'error',
|
73
|
-
//
|
74
|
-
// Warns when a deprecated command is used
|
75
|
-
deprecationWarnings: true,
|
76
|
-
//
|
77
|
-
// If you only want to run your tests until a specific amount of tests have failed use
|
78
|
-
// bail (default is 0 - don't bail, run all tests).
|
79
|
-
bail: 0,
|
80
|
-
//
|
81
|
-
// Set a base URL in order to shorten url command calls. If your `url` parameter starts
|
82
|
-
// with `/`, the base url gets prepended, not including the path portion of your baseUrl.
|
83
|
-
// If your `url` parameter starts without a scheme or `/` (like `some/path`), the base url
|
84
|
-
// gets prepended directly.
|
85
|
-
baseUrl: undefined, // This is important since WDIO 7+ does not accept an empty string for baseUrl
|
86
|
-
path: '',
|
87
|
-
//
|
88
|
-
// Default timeout for all waitFor* commands.
|
89
|
-
waitforTimeout: 10000,
|
90
|
-
//
|
91
|
-
// Default timeout in milliseconds for request
|
92
|
-
// if Selenium Grid doesn't send response
|
93
|
-
connectionRetryTimeout: 90000,
|
94
|
-
//
|
95
|
-
// Default request retries count
|
96
|
-
connectionRetryCount: 3,
|
97
|
-
//
|
98
|
-
// Test runner services
|
99
|
-
// Services take over a specific job you don't want to take care of. They enhance
|
100
|
-
// your test setup with almost no effort. Unlike plugins, they don't add new
|
101
|
-
// commands. Instead, they hook themselves up into the test process.
|
102
|
-
services: ['chromedriver'],
|
103
|
-
// options
|
104
|
-
chromeDriverArgs: ['--port=9515'], // default
|
105
|
-
// Framework you want to run your specs with.
|
106
|
-
// The following are supported: Mocha, Jasmine, and Cucumber
|
107
|
-
// see also: https://webdriver.io/docs/frameworks.html
|
108
|
-
//
|
109
|
-
// Make sure you have the wdio adapter package for the specific framework installed
|
110
|
-
// before running any tests.
|
111
|
-
framework: 'mocha',
|
112
|
-
//
|
113
|
-
// Test reporter for stdout.
|
114
|
-
// The only one supported by default is 'dot'
|
115
|
-
// see also: https://webdriver.io/docs/dot-reporter.html
|
116
|
-
reporters: ['dot', 'spec'],
|
117
|
-
|
118
|
-
//
|
119
|
-
// Options to be passed to Mocha.
|
120
|
-
// See the full list at http://mochajs.org/
|
121
|
-
mochaOpts: {
|
122
|
-
ui: 'bdd',
|
123
|
-
timeout: 60000
|
124
|
-
},
|
125
|
-
//
|
126
|
-
// =====
|
127
|
-
// Hooks
|
128
|
-
// =====
|
129
|
-
// WebdriverIO provides several hooks you can use to interfere with the test process in order to enhance
|
130
|
-
// it and to build services around it. You can either apply a single function or an array of
|
131
|
-
// methods to it. If one of them returns with a promise, WebdriverIO will wait until that promise got
|
132
|
-
// resolved to continue.
|
133
|
-
/**
|
134
|
-
* Gets executed once before all workers get launched.
|
135
|
-
* @param {Object} config wdio configuration object
|
136
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
137
|
-
*/
|
138
|
-
// onPrepare: function (config, capabilities) {
|
139
|
-
// },
|
140
|
-
/**
|
141
|
-
* Gets executed just before initialising the webdriver session and test framework. It allows you
|
142
|
-
* to manipulate configurations depending on the capability or spec.
|
143
|
-
* @param {Object} config wdio configuration object
|
144
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
145
|
-
* @param {Array.<String>} specs List of spec file paths that are to be run
|
146
|
-
*/
|
147
|
-
// beforeSession: function (config, capabilities, specs) {
|
148
|
-
// },
|
149
|
-
/**
|
150
|
-
* Gets executed before test execution begins. At this point you can access to all global
|
151
|
-
* variables like `browser`. It is the perfect place to define custom commands.
|
152
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
153
|
-
* @param {Array.<String>} specs List of spec file paths that are to be run
|
154
|
-
*/
|
155
|
-
before: function (capabilities, specs) {
|
156
|
-
browser.addCommand("isFocusedDeep", function () {
|
157
|
-
return browser.execute(function (elem) {
|
158
|
-
let activeElement = document.activeElement;
|
159
|
-
|
160
|
-
while (activeElement.shadowRoot) {
|
161
|
-
if (activeElement.shadowRoot.activeElement) {
|
162
|
-
activeElement = activeElement.shadowRoot.activeElement;
|
163
|
-
} else {
|
164
|
-
break;
|
165
|
-
}
|
166
|
-
}
|
167
|
-
return elem === activeElement;
|
168
|
-
}, this);
|
169
|
-
}, true);
|
170
|
-
|
171
|
-
browser.addCommand("setProperty", function(property, value) {
|
172
|
-
return browser.execute((elem, property, value) => {
|
173
|
-
return elem[property] = value;
|
174
|
-
}, this, property, value);
|
175
|
-
}, true);
|
176
|
-
|
177
|
-
browser.addCommand("setAttribute", function(attribute, value) {
|
178
|
-
return browser.execute((elem, attribute, value) => {
|
179
|
-
return elem.setAttribute(attribute, value);
|
180
|
-
}, this, attribute, value);
|
181
|
-
}, true);
|
182
|
-
|
183
|
-
browser.addCommand("removeAttribute", function(attribute) {
|
184
|
-
return browser.execute((elem, attribute) => {
|
185
|
-
return elem.removeAttribute(attribute);
|
186
|
-
}, this, attribute);
|
187
|
-
}, true);
|
188
|
-
|
189
|
-
browser.addCommand("hasClass", function(className) {
|
190
|
-
return browser.execute((elem, className) => {
|
191
|
-
return elem.classList.contains(className);
|
192
|
-
}, this, className);
|
193
|
-
}, true);
|
194
|
-
|
195
|
-
browser.addCommand("getStaticAreaItemClassName", function(selector) {
|
196
|
-
return browser.execute(async (selector) => {
|
197
|
-
const staticAreaItem = await document.querySelector(selector).getStaticAreaItemDomRef();
|
198
|
-
return staticAreaItem.host.classList[0];
|
199
|
-
}, selector);
|
200
|
-
}, false);
|
201
|
-
},
|
202
|
-
/**
|
203
|
-
* Runs before a WebdriverIO command gets executed.
|
204
|
-
* @param {String} commandName hook command name
|
205
|
-
* @param {Array} args arguments that command would receive
|
206
|
-
*/
|
207
|
-
beforeCommand: function (commandName, args) {
|
208
|
-
const waitFor = [
|
209
|
-
"$",
|
210
|
-
"$$",
|
211
|
-
"getAttribute",
|
212
|
-
"getCSSProperty",
|
213
|
-
"getHTML",
|
214
|
-
"getProperty",
|
215
|
-
"getSize",
|
216
|
-
"getStaticAreaItemClassName", // custom
|
217
|
-
"getText",
|
218
|
-
"getValue",
|
219
|
-
"hasClass", // custom
|
220
|
-
"isDisplayed",
|
221
|
-
"isDisplayedInViewport",
|
222
|
-
"isEnabled",
|
223
|
-
"isExisting",
|
224
|
-
"isFocused",
|
225
|
-
"isFocusedDeep", // custom
|
226
|
-
"shadow$",
|
227
|
-
"shadow$$",
|
228
|
-
];
|
229
|
-
if (waitFor.includes(commandName)) {
|
230
|
-
browser.executeAsync(function (done) {
|
231
|
-
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
232
|
-
});
|
233
|
-
}
|
234
|
-
},
|
235
|
-
|
236
|
-
/**
|
237
|
-
* Hook that gets executed before the suite starts
|
238
|
-
* @param {Object} suite suite details
|
239
|
-
*/
|
240
|
-
// beforeSuite: function (suite) {
|
241
|
-
// },
|
242
|
-
/**
|
243
|
-
* Function to be executed before a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
244
|
-
* @param {Object} test test details
|
245
|
-
*/
|
246
|
-
// beforeTest: function (test) {
|
247
|
-
// },
|
248
|
-
/**
|
249
|
-
* Hook that gets executed _before_ a hook within the suite starts (e.g. runs before calling
|
250
|
-
* beforeEach in Mocha)
|
251
|
-
*/
|
252
|
-
// beforeHook: function () {
|
253
|
-
// },
|
254
|
-
/**
|
255
|
-
* Hook that gets executed _after_ a hook within the suite starts (e.g. runs after calling
|
256
|
-
* afterEach in Mocha)
|
257
|
-
*/
|
258
|
-
// afterHook: function () {
|
259
|
-
// },
|
260
|
-
/**
|
261
|
-
* Function to be executed after a test (in Mocha/Jasmine) or a step (in Cucumber) starts.
|
262
|
-
* @param {Object} test test details
|
263
|
-
*/
|
264
|
-
// afterTest: function (test) {
|
265
|
-
// },
|
266
|
-
/**
|
267
|
-
* Hook that gets executed after the suite has ended
|
268
|
-
* @param {Object} suite suite details
|
269
|
-
*/
|
270
|
-
// afterSuite: function (suite) {
|
271
|
-
// },
|
272
|
-
|
273
|
-
/**
|
274
|
-
* Runs after a WebdriverIO command gets executed
|
275
|
-
* @param {String} commandName hook command name
|
276
|
-
* @param {Array} args arguments that command would receive
|
277
|
-
* @param {Number} result 0 - command success, 1 - command error
|
278
|
-
* @param {Object} error error object if any
|
279
|
-
*/
|
280
|
-
afterCommand: function (commandName, args, result, error) {
|
281
|
-
|
282
|
-
// url -> set configuration first
|
283
|
-
if (commandName === "url" && !args[0].includes("do-not-change-configuration")) {
|
284
|
-
browser.execute(function() {
|
285
|
-
window["sap-ui-webcomponents-bundle"].configuration.setNoConflict(true);
|
286
|
-
});
|
287
|
-
}
|
288
|
-
|
289
|
-
const waitFor = [
|
290
|
-
"addValue",
|
291
|
-
"clearValue",
|
292
|
-
"click",
|
293
|
-
"doubleClick",
|
294
|
-
"dragAndDrop",
|
295
|
-
"keys",
|
296
|
-
"pause",
|
297
|
-
"removeAttribute", // custom
|
298
|
-
"setAttribute", // custom
|
299
|
-
"setProperty", // custom
|
300
|
-
"setValue",
|
301
|
-
"setWindowSize",
|
302
|
-
"touchAction",
|
303
|
-
"url"
|
304
|
-
];
|
305
|
-
if (waitFor.includes(commandName)) {
|
306
|
-
browser.executeAsync(function (done) {
|
307
|
-
window["sap-ui-webcomponents-bundle"].renderFinished().then(done);
|
308
|
-
});
|
309
|
-
}
|
310
|
-
},
|
311
|
-
/**
|
312
|
-
* Gets executed after all tests are done. You still have access to all global variables from
|
313
|
-
* the test.
|
314
|
-
* @param {Number} result 0 - test pass, 1 - test fail
|
315
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
316
|
-
* @param {Array.<String>} specs List of spec file paths that ran
|
317
|
-
*/
|
318
|
-
// after: function (result, capabilities, specs) {
|
319
|
-
// },
|
320
|
-
/**
|
321
|
-
* Gets executed right after terminating the webdriver session.
|
322
|
-
* @param {Object} config wdio configuration object
|
323
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
324
|
-
* @param {Array.<String>} specs List of spec file paths that ran
|
325
|
-
*/
|
326
|
-
// afterSession: function (config, capabilities, specs) {
|
327
|
-
// },
|
328
|
-
/**
|
329
|
-
* Gets executed after all workers got shut down and the process is about to exit.
|
330
|
-
* @param {Object} exitCode 0 - success, 1 - fail
|
331
|
-
* @param {Object} config wdio configuration object
|
332
|
-
* @param {Array.<Object>} capabilities list of capabilities details
|
333
|
-
* @param {<Object>} results object containing test results
|
334
|
-
*/
|
335
|
-
// onComplete: function(exitCode, config, capabilities, results) {
|
336
|
-
// },
|
337
|
-
/**
|
338
|
-
* Gets executed when a refresh happens.
|
339
|
-
* @param {String} oldSessionId session ID of the old session
|
340
|
-
* @param {String} newSessionId session ID of the new session
|
341
|
-
*/
|
342
|
-
//onReload: function(oldSessionId, newSessionId) {
|
343
|
-
//}
|
344
|
-
}
|
@@ -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,40 +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
|
-
<code>{{toKebabCase this.name}}</code>
|
25
|
-
{{/if}}
|
26
|
-
</div>
|
27
|
-
<div class="cell api-table-content-cell">{{this.type}}</div>
|
28
|
-
<div class="cell api-table-content-cell">{{this.defaultValue}}</div>
|
29
|
-
<div class="cell api-table-content-cell api-table-content-cell-description">
|
30
|
-
{{{this.description}}}
|
31
|
-
{{#if this.since}}
|
32
|
-
<div class="api-table-content-cell-bold api-table-content-cell-since">since v{{{this.since}}}</div>
|
33
|
-
{{/if}}
|
34
|
-
</div>
|
35
|
-
</div>
|
36
|
-
{{/each}}
|
37
|
-
|
38
|
-
</div>
|
39
|
-
{{/if}}`
|
40
|
-
};
|
@@ -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
|
-
};
|