@ui5/webcomponents-tools 0.0.0-bef62af04 → 0.0.0-bf8366eb6

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 (109) hide show
  1. package/CHANGELOG.md +1314 -0
  2. package/README.md +6 -6
  3. package/assets-meta.js +17 -6
  4. package/bin/dev.js +1 -5
  5. package/components-package/eslint.js +36 -0
  6. package/components-package/nps.js +109 -70
  7. package/components-package/postcss.components.js +1 -21
  8. package/components-package/postcss.themes.js +1 -23
  9. package/components-package/vite.config.js +13 -0
  10. package/components-package/wdio.js +107 -37
  11. package/icons-collection/nps.js +51 -18
  12. package/lib/amd-to-es6/index.js +102 -0
  13. package/lib/amd-to-es6/no-remaining-require.js +33 -0
  14. package/lib/cem/custom-elements-manifest.config.mjs +501 -0
  15. package/lib/cem/event.mjs +131 -0
  16. package/lib/cem/schema-internal.json +1357 -0
  17. package/lib/cem/schema.json +1098 -0
  18. package/lib/cem/types-internal.d.ts +796 -0
  19. package/lib/cem/types.d.ts +736 -0
  20. package/lib/cem/utils.mjs +384 -0
  21. package/lib/cem/validate.js +70 -0
  22. package/lib/copy-and-watch/index.js +24 -1
  23. package/lib/copy-list/index.js +17 -17
  24. package/lib/create-icons/index.js +126 -58
  25. package/lib/create-illustrations/index.js +157 -45
  26. package/lib/create-new-component/index.js +61 -101
  27. package/lib/create-new-component/tsFileContentTemplate.js +71 -0
  28. package/lib/css-processors/css-processor-component-styles.mjs +48 -0
  29. package/lib/css-processors/css-processor-components.mjs +77 -0
  30. package/lib/css-processors/css-processor-themes.mjs +79 -0
  31. package/lib/css-processors/scope-variables.mjs +49 -0
  32. package/lib/css-processors/shared.mjs +76 -0
  33. package/lib/dev-server/custom-hot-update-plugin.js +39 -0
  34. package/lib/dev-server/dev-server.js +66 -0
  35. package/lib/dev-server/ssr-dom-shim-loader.js +26 -0
  36. package/lib/dev-server/virtual-index-html-plugin.js +52 -0
  37. package/lib/generate-js-imports/illustrations.js +86 -0
  38. package/lib/generate-json-imports/i18n.js +35 -55
  39. package/lib/generate-json-imports/themes.js +30 -45
  40. package/lib/hbs2lit/src/compiler.js +24 -4
  41. package/lib/hbs2lit/src/includesReplacer.js +5 -5
  42. package/lib/hbs2lit/src/litVisitor2.js +95 -24
  43. package/lib/hbs2lit/src/svgProcessor.js +12 -5
  44. package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +32 -4
  45. package/lib/hbs2ui5/index.js +56 -23
  46. package/lib/i18n/defaults.js +65 -57
  47. package/lib/i18n/toJSON.js +12 -11
  48. package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
  49. package/lib/remove-dev-mode/remove-dev-mode.mjs +37 -0
  50. package/lib/scoping/get-all-tags.js +2 -9
  51. package/lib/scoping/lint-src.js +8 -7
  52. package/lib/scoping/missing-dependencies.js +65 -0
  53. package/lib/scoping/report-tags-usage.js +28 -0
  54. package/lib/scoping/scope-test-pages.js +2 -1
  55. package/lib/test-runner/test-runner.js +71 -0
  56. package/package.json +38 -39
  57. package/bin/init-ui5-package.js +0 -3
  58. package/components-package/rollup.js +0 -216
  59. package/lib/documentation/index.js +0 -165
  60. package/lib/documentation/templates/api-component-since.js +0 -3
  61. package/lib/documentation/templates/api-css-variables-section.js +0 -24
  62. package/lib/documentation/templates/api-events-section.js +0 -35
  63. package/lib/documentation/templates/api-methods-section.js +0 -26
  64. package/lib/documentation/templates/api-properties-section.js +0 -40
  65. package/lib/documentation/templates/api-slots-section.js +0 -28
  66. package/lib/documentation/templates/template.js +0 -38
  67. package/lib/esm-abs-to-rel/index.js +0 -54
  68. package/lib/hash/config.js +0 -10
  69. package/lib/hash/generate.js +0 -19
  70. package/lib/hash/upToDate.js +0 -31
  71. package/lib/init-package/index.js +0 -136
  72. package/lib/init-package/resources/.eslintignore +0 -3
  73. package/lib/init-package/resources/bundle.es5.js +0 -25
  74. package/lib/init-package/resources/bundle.esm.js +0 -31
  75. package/lib/init-package/resources/config/.eslintrc.js +0 -1
  76. package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
  77. package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
  78. package/lib/init-package/resources/config/rollup.config.js +0 -1
  79. package/lib/init-package/resources/config/wdio.conf.js +0 -1
  80. package/lib/init-package/resources/package-scripts.js +0 -11
  81. package/lib/init-package/resources/src/Assets.js +0 -5
  82. package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
  83. package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
  84. package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
  85. package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
  86. package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
  87. package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
  88. package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
  89. package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
  90. package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
  91. package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
  92. package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
  93. package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
  94. package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
  95. package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
  96. package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
  97. package/lib/init-package/resources/test/pages/index.html +0 -56
  98. package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
  99. package/lib/jsdoc/config.json +0 -29
  100. package/lib/jsdoc/plugin.js +0 -2427
  101. package/lib/jsdoc/template/publish.js +0 -4101
  102. package/lib/polyfill-placeholder/index.js +0 -5
  103. package/lib/postcss-css-to-esm/index.js +0 -45
  104. package/lib/postcss-css-to-json/index.js +0 -31
  105. package/lib/postcss-new-files/index.js +0 -36
  106. package/lib/replace-global-core/index.js +0 -20
  107. package/lib/serve/index.js +0 -46
  108. package/lib/serve/serve.json +0 -3
  109. package/package-lock.json +0 -48
@@ -0,0 +1,28 @@
1
+ const fs = require("fs");
2
+ const glob = require("glob");
3
+ const path = require("path");
4
+ const process = require("process");
5
+
6
+ // gather all tags from all files
7
+ const tags = new Set();
8
+ const files = glob.sync(path.join(process.argv[2], "src/**/*.js"));
9
+ files.forEach(file => {
10
+ const content = `${fs.readFileSync(file)}`;
11
+ const matches = content.match(/tag: "(.*?)",/);
12
+ if (matches) {
13
+ tags.add(matches[1]);
14
+ }
15
+ });
16
+
17
+ // report all usages of any tag within any file, which is not the tag definition and is not hasAttribute
18
+ files.forEach(file => {
19
+ const content = `${fs.readFileSync(file)}`;
20
+ const lines = content.split("\n");
21
+ lines.forEach(line => {
22
+ tags.forEach(tag => {
23
+ if (line.includes(`"${tag}"`) && !line.includes(`tag: "${tag}",`) && !line.includes(`hasAttribute("${tag}")`)) {
24
+ console.log(`${file}: ${line.trim()}`);
25
+ }
26
+ });
27
+ });
28
+ });
@@ -18,6 +18,7 @@ const replaceTagsHTML = content => {
18
18
 
19
19
  // Replace tags in any content
20
20
  const replaceTagsAny = content => {
21
+ console.log(tags.length);
21
22
  tags.forEach(tag => {
22
23
  content = content.replace(new RegExp(`(^|[^\-_A-Za-z0-9])(${tag})([^\-_A-Za-z0-9]|$)`, "g"), `$1$2-${suffix}$3`);
23
24
  });
@@ -27,7 +28,7 @@ const replaceTagsAny = content => {
27
28
  // Replace bundle names and HTML tag names in test pages
28
29
  glob.sync(path.join(root, "/**/*.html")).forEach(file => {
29
30
  let content = String(fs.readFileSync(file));
30
- content = content.replace(/bundle\.(.*?)\.js/g, `bundle.scoped.$1.js`);
31
+ content = content.replace("%VITE_BUNDLE_PATH%", "%VITE_BUNDLE_PATH_SCOPED%");
31
32
  content = replaceTagsHTML(content);
32
33
  fs.writeFileSync(file, content);
33
34
  });
@@ -0,0 +1,71 @@
1
+ const child_process = require("child_process");
2
+ const { readFileSync } = require("fs");
3
+ const path = require("path");
4
+ const fs = require("fs");
5
+
6
+ // search for dev-server port
7
+ // start in current folder
8
+ // traversing upwards in case of mono repo tests and dev-server running in root folder of repository
9
+ let devServerFolder = process.cwd();
10
+ let devServerPort;
11
+ while (true) {
12
+ try {
13
+ devServerPort = readFileSync(path.join(devServerFolder, ".dev-server-port")).toString();
14
+ break; // found
15
+ } catch (e) {
16
+ // file not found
17
+ if (devServerFolder === path.dirname(devServerFolder)) {
18
+ break; // reached root folder "/"
19
+ }
20
+ devServerFolder = path.dirname(devServerFolder);
21
+ }
22
+ }
23
+
24
+ // check if we are in a monorepo and extract path from package.json
25
+ let packageRepositoryPath = "";
26
+ const pkg = require(path.join(process.cwd(), "package.json"));
27
+ packageRepositoryPath = pkg.repository ? pkg.repository.directory : "";
28
+
29
+ // construct base url
30
+ // use devServerPort if a dev server is running, otherwise let the baseUrl in the wdio config be used
31
+ // if a dev server is running in the root of a mono repo, append tha package path like this
32
+ // http://localhost:${devServerPort}/packages/main/
33
+ let baseUrl = "";
34
+ if (devServerPort) {
35
+ console.log(`Found port ${devServerPort} from '${path.join(devServerFolder, ".dev-server-port")}'`);
36
+ const devServerInRoot = !devServerFolder.includes(packageRepositoryPath);
37
+ if (devServerInRoot) {
38
+ baseUrl = `--base-url http://localhost:${devServerPort}/${packageRepositoryPath}/`;
39
+ } else {
40
+ baseUrl = `--base-url http://localhost:${devServerPort}/`;
41
+ }
42
+ }
43
+
44
+ if (!baseUrl) {
45
+ console.log("No dev server running, running tests served from `dist`, make sure it is up to date");
46
+ }
47
+
48
+ // add single spec parameter if passed
49
+ let spec = "";
50
+ if (process.argv.length === 3) {
51
+ const specFile = process.argv[2];
52
+ spec = `--spec ${specFile}`;
53
+ }
54
+
55
+ // more parameters - pass them to wdio
56
+ let restParams = "";
57
+ if (process.argv.length > 3) {
58
+ restParams = process.argv.slice(2).join(" ");
59
+ }
60
+
61
+ let wdioConfig = "";
62
+ if (fs.existsSync("config/wdio.conf.cjs")) {
63
+ wdioConfig = "config/wdio.conf.cjs";
64
+ } else if (fs.existsSync("config/wdio.conf.js")) {
65
+ wdioConfig = "config/wdio.conf.js";
66
+ }
67
+
68
+ // run wdio with calculated parameters
69
+ const cmd = `yarn cross-env WDIO_LOG_LEVEL=error wdio ${wdioConfig} ${spec} ${baseUrl} ${restParams}`;
70
+ console.log(`executing: ${cmd}`);
71
+ child_process.execSync(cmd, {stdio: 'inherit'});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/webcomponents-tools",
3
- "version": "0.0.0-bef62af04",
3
+ "version": "0.0.0-bf8366eb6",
4
4
  "description": "UI5 Web Components: webcomponents.tools",
5
5
  "author": "SAP SE (https://www.sap.com)",
6
6
  "license": "Apache-2.0",
@@ -13,8 +13,7 @@
13
13
  "scripts": {},
14
14
  "bin": {
15
15
  "wc-dev": "bin/dev.js",
16
- "wc-create-ui5-element": "bin/create-ui5-element.js",
17
- "wc-init-ui5-package": "bin/init-ui5-package.js"
16
+ "wc-create-ui5-element": "bin/create-ui5-element.js"
18
17
  },
19
18
  "repository": {
20
19
  "type": "git",
@@ -22,63 +21,63 @@
22
21
  "directory": "packages/tools"
23
22
  },
24
23
  "dependencies": {
25
- "@babel/cli": "^7.13.10",
26
- "@babel/core": "^7.13.10",
27
- "@babel/plugin-proposal-object-rest-spread": "^7.13.8",
28
- "@babel/preset-env": "^7.13.10",
29
- "@rollup/plugin-babel": "^5.3.0",
30
- "@rollup/plugin-json": "^4.1.0",
31
- "@rollup/plugin-node-resolve": "^11.2.0",
32
- "@rollup/plugin-url": "^6.0.0",
33
- "@wdio/cli": "^7.2.0",
34
- "@wdio/dot-reporter": "^7.2.0",
35
- "@wdio/local-runner": "^7.2.0",
36
- "@wdio/mocha-framework": "^7.2.0",
37
- "@wdio/spec-reporter": "^7.2.0",
38
- "@wdio/sync": "^7.2.0",
39
- "@webcomponents/webcomponentsjs": "^2.5.0",
24
+ "@custom-elements-manifest/analyzer": "^0.8.4",
25
+ "@typescript-eslint/eslint-plugin": "^6.9.0",
26
+ "@typescript-eslint/parser": "^6.9.0",
27
+ "@wdio/cli": "^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",
33
+ "ajv": "^8.12.0",
34
+ "cem-plugin-vs-code-custom-data-generator": "^1.4.2",
40
35
  "chai": "^4.3.4",
41
36
  "child_process": "^1.0.2",
42
37
  "chokidar": "^3.5.1",
43
- "chokidar-cli": "^2.1.0",
44
- "clean-css": "^5.1.1",
45
- "colors": "^1.4.0",
38
+ "chokidar-cli": "^3.0.0",
46
39
  "command-line-args": "^5.1.1",
40
+ "comment-parser": "^1.4.0",
47
41
  "concurrently": "^6.0.0",
48
42
  "cross-env": "^7.0.3",
49
- "cssnano": "^4.1.10",
43
+ "custom-element-jet-brains-integration": "^1.4.4",
50
44
  "escodegen": "^2.0.0",
51
45
  "eslint": "^7.22.0",
52
46
  "eslint-config-airbnb-base": "^14.2.1",
53
47
  "eslint-plugin-import": "^2.22.1",
54
48
  "esprima": "^4.0.1",
55
- "folder-hash": "^4.0.1",
56
49
  "getopts": "^2.3.0",
57
50
  "glob": "^7.1.6",
51
+ "glob-parent": "^6.0.2",
52
+ "globby": "^13.1.1",
58
53
  "handlebars": "^4.7.7",
59
- "is-port-reachable": "^3.0.0",
60
- "jsdoc": "^3.6.6",
54
+ "is-port-reachable": "^3.1.0",
61
55
  "json-beautify": "^1.1.1",
62
56
  "mkdirp": "^1.0.4",
63
- "npm-run-all": "^4.1.3",
64
57
  "nps": "^5.10.0",
65
- "postcss": "^8.2.10",
66
- "postcss-cli": "^8.3.1",
67
- "postcss-combine-duplicated-selectors": "^10.0.2",
68
- "postcss-import": "^14.0.0",
58
+ "postcss": "^8.4.5",
59
+ "postcss-cli": "^9.1.0",
60
+ "postcss-selector-parser": "^6.0.10",
61
+ "prompts": "^2.4.2",
69
62
  "properties-reader": "^2.2.0",
70
- "puppeteer": "^8.0.0",
71
63
  "recursive-readdir": "^2.2.2",
64
+ "resolve": "^1.20.0",
72
65
  "rimraf": "^3.0.2",
73
- "rollup": "^2.41.4",
74
- "rollup-plugin-filesize": "^9.1.1",
75
- "rollup-plugin-livereload": "^2.0.0",
76
- "rollup-plugin-string": "^3.0.0",
77
- "rollup-plugin-terser": "^7.0.2",
78
- "serve": "^12.0.0",
79
- "wdio-chromedriver-service": "^7.0.0"
66
+ "slash": "3.0.0",
67
+ "vite": "^4.4.9",
68
+ "wdio-chromedriver-service": "^7.3.2"
80
69
  },
81
70
  "peerDependencies": {
82
- "chromedriver": "*"
71
+ "chromedriver": "*",
72
+ "typescript": "^4.9.4"
73
+ },
74
+ "peerDependenciesMeta": {
75
+ "typescript": {
76
+ "optional": true
77
+ }
78
+ },
79
+ "devDependencies": {
80
+ "esbuild": "^0.19.9",
81
+ "yargs": "^17.5.1"
83
82
  }
84
83
  }
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require("../lib/init-package/index.js");
@@ -1,216 +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 colors = require("colors/safe");
10
- const filesize = require("rollup-plugin-filesize");
11
- const livereload = require("rollup-plugin-livereload");
12
-
13
- const packageFile = JSON.parse(fs.readFileSync("./package.json"));
14
- const packageName = packageFile.name;
15
- const DEPLOY_PUBLIC_PATH = process.env.DEPLOY_PUBLIC_PATH || "";
16
-
17
- const warningsToSkip = [{
18
- warningCode: "THIS_IS_UNDEFINED",
19
- filePath: /.+zxing.+/,
20
- }];
21
-
22
- function ui5DevImportCheckerPlugin() {
23
- return {
24
- name: "ui5-dev-import-checker-plugin",
25
- transform(code, file) {
26
- const re = new RegExp(`^import.*"${packageName}/`);
27
- if (re.test(code)) {
28
- throw new Error(`illegal import in ${file}`);
29
- }
30
- },
31
- };
32
- }
33
-
34
- function onwarn(warning, warn) {
35
- // Skip warning for known false positives that will otherwise polute the log
36
- let skip = warningsToSkip.find(warningToSkip => {
37
- let loc, file;
38
- return warning.code === warningToSkip.warningCode
39
- && (loc = warning.loc)
40
- && (file = loc.file)
41
- && file.match(warningToSkip.filePath);
42
- });
43
- if (skip) {
44
- return;
45
- }
46
-
47
- // warn everything else
48
- warn( warning );
49
- }
50
-
51
- const reportedForPackages = new Set(); // sometimes writeBundle is called more than once per bundle -> suppress extra messages
52
- function ui5DevReadyMessagePlugin() {
53
- return {
54
- name: "ui5-dev-message-ready-plugin",
55
- writeBundle: (assets, bundle) => {
56
- if (reportedForPackages.has(packageName)) {
57
- return;
58
- }
59
- console.log(colors.blue(`${colors.bold(packageName)} successfully built!`));
60
-
61
- if (fs.existsSync(".port")) {
62
- const port = `${fs.readFileSync(".port")}`;
63
- if (port) {
64
- console.log(colors.blue(`Navigate to: ${colors.bold(`http://localhost:${port}/test-resources/pages/`)}`));
65
- }
66
- }
67
- reportedForPackages.add(packageName);
68
- },
69
- };
70
- }
71
-
72
- const getPlugins = ({ transpile }) => {
73
- const plugins = [];
74
- if (!process.env.DEV) {
75
- plugins.push(filesize(
76
- {
77
- reporter(options, bundle, {
78
- minSize, gzipSize, brotliSize, bundleSize,
79
- fileName,
80
- // "showBeforeSizes: release"
81
- lastVersion,
82
- // "showBeforeSizes: "release" or "showBeforeSizes": "build"
83
- bundleSizeBefore, brotliSizeBefore, minSizeBefore, gzipSizeBefore,
84
- }) {
85
- // If a promise is returned, it will be awaited before rendering.
86
- return `${fileName.padEnd(35)} ${minSize} / gzipped: ${gzipSize}`;
87
- },
88
- },
89
-
90
- ));
91
- }
92
-
93
- const publicPath = DEPLOY_PUBLIC_PATH;
94
-
95
- plugins.push(ui5DevImportCheckerPlugin());
96
-
97
- if (!transpile) {
98
- plugins.push(json({
99
- include: [
100
- /.*assets\/.*\.json/,
101
- ],
102
- namedExports: false,
103
- }));
104
- }
105
-
106
- if (transpile) {
107
- plugins.push(url({
108
- limit: 0,
109
- include: [
110
- /.*assets\/.*\.json/,
111
- ],
112
- emitFiles: true,
113
- fileName: "[name].[hash][extname]",
114
- publicPath,
115
- }));
116
- }
117
-
118
- if (transpile) {
119
- plugins.push(babel({
120
- presets: ["@babel/preset-env"],
121
- exclude: /node_modules\/(?!(lit-html|@ui5\/webcomponents))/, // exclude all node_modules/ except lit-html and all starting with @ui5/webcomponents
122
- sourcemap: true,
123
- babelHelpers: "bundled",
124
- }));
125
- }
126
-
127
- plugins.push(nodeResolve());
128
-
129
- if (!process.env.DEV) {
130
- plugins.push(terser({
131
- numWorkers: 1,
132
- }));
133
- }
134
-
135
- const es6DevMain = process.env.DEV && !transpile && packageName === "@ui5/webcomponents";
136
- if (es6DevMain && os.platform() !== "win32") {
137
- plugins.push(livereload({
138
- watch: [
139
- "dist/resources/bundle.esm.js",
140
- "dist/**/*.html",
141
- "dist/**/*.json",
142
- ],
143
- }));
144
- }
145
-
146
- if (process.env.DEV) {
147
- plugins.push(ui5DevReadyMessagePlugin());
148
- }
149
-
150
- return plugins;
151
- };
152
-
153
- const getES6Config = (input = "bundle.esm.js") => {
154
- return [{
155
- input,
156
- output: {
157
- dir: "dist/resources",
158
- format: "esm",
159
- sourcemap: true,
160
- },
161
- moduleContext: id => {
162
- if (typeof id === "string" && id.includes("url-search-params-polyfill")) {
163
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
164
- return "window";
165
- }
166
- },
167
- watch: {
168
- clearScreen: false,
169
- },
170
- plugins: getPlugins({ transpile: false }),
171
- onwarn: onwarn,
172
- }];
173
- };
174
-
175
- const getES5Config = (input = "bundle.es5.js") => {
176
- return [{
177
- input,
178
- output: {
179
- dir: "dist/resources",
180
- format: "iife",
181
- inlineDynamicImports: true,
182
- name: "sap-ui-webcomponents-bundle",
183
- extend: "true", // Whether or not to extend the global variable defined by the name option in umd or iife formats.
184
- sourcemap: true,
185
- },
186
- moduleContext: id => {
187
- if (id.includes("url-search-params-polyfill")) {
188
- // suppress the rollup error for this module as it uses this in the global scope correctly even without changing the context here
189
- return "window";
190
- }
191
- },
192
- watch: {
193
- clearScreen: false,
194
- },
195
- plugins: getPlugins({ transpile: true }),
196
- onwarn: onwarn,
197
- }];
198
- };
199
-
200
- let config = getES6Config();
201
-
202
- if (process.env.ES5_BUILD && fs.existsSync("bundle.es5.js")) {
203
- config = config.concat(getES5Config());
204
- }
205
-
206
- if (process.env.SCOPE) {
207
- if (fs.existsSync("bundle.scoped.esm.js")) {
208
- config = config.concat(getES6Config("bundle.scoped.esm.js"));
209
-
210
- if (fs.existsSync("bundle.scoped.es5.js") && process.env.ES5_BUILD) {
211
- config = config.concat(getES5Config("bundle.scoped.es5.js"));
212
- }
213
- }
214
- }
215
-
216
- 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,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
- };