@ui5/webcomponents-tools 2.1.0 → 2.2.0-rc.0
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 +19 -0
- package/components-package/cypress/support/component-index.html +1 -0
- package/components-package/cypress/support/component.d.ts +20 -0
- package/components-package/cypress/support/component.js +31 -1
- package/components-package/cypress.config.js +1 -1
- package/components-package/eslint.js +4 -1
- package/lib/generate-json-imports/i18n.js +38 -27
- package/lib/generate-json-imports/themes.js +8 -3
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +5 -5
- package/package.json +3 -2
- package/tsconfig.json +16 -0
- package/types/index.d.ts +1 -0
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,25 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [2.2.0-rc.0](https://github.com/SAP/ui5-webcomponents/compare/v2.1.1...v2.2.0-rc.0) (2024-08-08)
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* **core:** add asset files with fetch URLs ([#9591](https://github.com/SAP/ui5-webcomponents/issues/9591)) ([f039cf6](https://github.com/SAP/ui5-webcomponents/commit/f039cf6e96e43fbc45e55e53871c91c9ee8e4179))
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## [2.1.1](https://github.com/SAP/ui5-webcomponents/compare/v2.1.0...v2.1.1) (2024-08-02)
|
18
|
+
|
19
|
+
**Note:** Version bump only for package @ui5/webcomponents-tools
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
6
25
|
# [2.1.0](https://github.com/SAP/ui5-webcomponents/compare/v2.1.0-rc.3...v2.1.0) (2024-08-02)
|
7
26
|
|
8
27
|
**Note:** Version bump only for package @ui5/webcomponents-tools
|
@@ -5,6 +5,7 @@
|
|
5
5
|
<meta charset="utf-8">
|
6
6
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
7
7
|
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
8
|
+
<meta name="sap-allowedThemeOrigins" content="https://example.com">
|
8
9
|
<title>Components App</title>
|
9
10
|
<script data-ui5-config type="application/json">{}</script>
|
10
11
|
</head>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/// <reference types="cypress" />
|
2
|
+
import { RenderOptions, HTMLTemplateResult } from 'lit';
|
3
|
+
export type Renderable = HTMLTemplateResult;
|
4
|
+
export interface MountUI5Options extends MountLitTemplateOptions {
|
5
|
+
ui5Configuration: object;
|
6
|
+
}
|
7
|
+
export type MountOptions = Partial<MountUI5Options>;
|
8
|
+
export declare function mount<T extends keyof HTMLElementTagNameMap = any>(component: string | Renderable, options?: MountOptions): Cypress.Chainable<JQuery<HTMLElementTagNameMap[T]>>;
|
9
|
+
declare global {
|
10
|
+
namespace Cypress {
|
11
|
+
interface Chainable {
|
12
|
+
/**
|
13
|
+
* Mount your component into Cypress sandbox
|
14
|
+
* @param component content to render by lit-html render function
|
15
|
+
* @param options render options for custom rendering
|
16
|
+
*/
|
17
|
+
mount: typeof mount;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
@@ -1,4 +1,34 @@
|
|
1
|
+
import { setupHooks } from '@cypress/mount-utils';
|
2
|
+
import { unsafeHTML } from 'lit-html/directives/unsafe-html.js';
|
1
3
|
import { mount } from 'cypress-ct-lit'
|
2
4
|
import "./commands.js";
|
3
5
|
|
4
|
-
|
6
|
+
let dispose;
|
7
|
+
|
8
|
+
function cleanup() {
|
9
|
+
dispose?.();
|
10
|
+
}
|
11
|
+
|
12
|
+
function ui5Mount(component, options = {}) {
|
13
|
+
const configurationScript = document.head.querySelector("script[data-ui5-config]")
|
14
|
+
cleanup();
|
15
|
+
|
16
|
+
if (options.ui5Configuration) {
|
17
|
+
configurationScript.innerHTML = JSON.stringify(options.ui5Configuration);
|
18
|
+
|
19
|
+
}
|
20
|
+
|
21
|
+
dispose = () => {
|
22
|
+
configurationScript.innerHTML = "{}";
|
23
|
+
}
|
24
|
+
|
25
|
+
if (typeof component === "string") {
|
26
|
+
return mount(unsafeHTML(component), options)
|
27
|
+
}
|
28
|
+
|
29
|
+
return mount(component, options)
|
30
|
+
}
|
31
|
+
|
32
|
+
setupHooks(cleanup);
|
33
|
+
|
34
|
+
Cypress.Commands.add('mount', ui5Mount)
|
@@ -6,7 +6,7 @@ module.exports = defineConfig({
|
|
6
6
|
component: {
|
7
7
|
supportFile: path.join(__dirname, "cypress/support/component.js"),
|
8
8
|
indexHtmlFile: path.join(__dirname, "cypress/support/component-index.html"),
|
9
|
-
specPattern: "
|
9
|
+
specPattern: "**/specs/*.cy.{js,ts}",
|
10
10
|
devServer: {
|
11
11
|
framework: 'cypress-ct-lit',
|
12
12
|
bundler: 'vite',
|
@@ -14,7 +14,10 @@ const overrides = tsMode ? [{
|
|
14
14
|
"plugin:@typescript-eslint/recommended-requiring-type-checking"
|
15
15
|
],
|
16
16
|
parserOptions: {
|
17
|
-
"project": [
|
17
|
+
"project": [
|
18
|
+
"./tsconfig.json",
|
19
|
+
"./cypress/tsconfig.json",
|
20
|
+
],
|
18
21
|
EXPERIMENTAL_useSourceOfProjectReferenceRedirect: true,
|
19
22
|
},
|
20
23
|
rules: {
|
@@ -4,14 +4,43 @@ const path = require('path');
|
|
4
4
|
const isTypeScript = process.env.UI5_TS;
|
5
5
|
const ext = isTypeScript ? 'ts' : 'js';
|
6
6
|
|
7
|
+
|
8
|
+
const getContent = function(caseLines, languagesKeysStringArray, packageName) {
|
9
|
+
return `// @ts-nocheck
|
10
|
+
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
11
|
+
|
12
|
+
const importMessageBundle = async (localeId) => {
|
13
|
+
switch (localeId) {
|
14
|
+
${caseLines}
|
15
|
+
default: throw "unknown locale"
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
const importAndCheck = async (localeId) => {
|
20
|
+
const data = await importMessageBundle(localeId);
|
21
|
+
if (typeof data === "string" && data.endsWith(".json")) {
|
22
|
+
throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
|
23
|
+
}
|
24
|
+
return data;
|
25
|
+
}
|
26
|
+
|
27
|
+
const localeIds = [${languagesKeysStringArray}];
|
28
|
+
|
29
|
+
localeIds.forEach(localeId => {
|
30
|
+
registerI18nLoader("${packageName}", localeId, importAndCheck);
|
31
|
+
});
|
32
|
+
`;
|
33
|
+
}
|
34
|
+
|
7
35
|
const generate = async () => {
|
8
36
|
|
9
37
|
const packageName = JSON.parse(await fs.readFile("package.json")).name;
|
10
38
|
|
11
39
|
const inputFolder = path.normalize(process.argv[2]);
|
12
40
|
const outputFileDynamic = path.normalize(`${process.argv[3]}/i18n.${ext}`);
|
41
|
+
const outputFileFetchMetaResolve = path.normalize(`${process.argv[3]}/i18n-fetch.${ext}`);
|
13
42
|
|
14
|
-
// All languages present in the file system
|
43
|
+
// All languages present in the file system
|
15
44
|
const files = await fs.readdir(inputFolder);
|
16
45
|
const languages = files.map(file => {
|
17
46
|
const matches = file.match(/messagebundle_(.+?).json$/);
|
@@ -19,50 +48,32 @@ const generate = async () => {
|
|
19
48
|
}).filter(key => !!key);
|
20
49
|
|
21
50
|
let contentDynamic;
|
51
|
+
let contentFetchMetaResolve;
|
22
52
|
|
23
|
-
// No i18n - just import dependencies, if any
|
53
|
+
// No i18n - just import dependencies, if any
|
24
54
|
if (languages.length === 0) {
|
25
55
|
contentDynamic = "";
|
26
|
-
|
56
|
+
contentFetchMetaResolve = "";
|
57
|
+
// There is i18n - generate the full file
|
27
58
|
} else {
|
28
59
|
// Keys for the array
|
29
60
|
const languagesKeysStringArray = languages.map(key => `"${key}",`).join("\n\t");
|
30
61
|
|
31
62
|
// Actual imports for json assets
|
32
63
|
const dynamicImportsString = languages.map(key => ` case "${key}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-messagebundle-${key}" */ "../assets/i18n/messagebundle_${key}.json")).default;`).join("\n");
|
64
|
+
const fetchMetaResolveString = languages.map(key => ` case "${key}": return (await fetch(new URL("../assets/i18n/messagebundle_${key}.json", import.meta.url))).json();`).join("\n");
|
33
65
|
|
34
66
|
// Resulting file content
|
35
|
-
contentDynamic = `// @ts-nocheck
|
36
|
-
import { registerI18nLoader } from "@ui5/webcomponents-base/dist/asset-registries/i18n.js";
|
37
|
-
|
38
|
-
const importMessageBundle = async (localeId) => {
|
39
|
-
switch (localeId) {
|
40
|
-
${dynamicImportsString}
|
41
|
-
default: throw "unknown locale"
|
42
|
-
}
|
43
|
-
}
|
44
|
-
|
45
|
-
const importAndCheck = async (localeId) => {
|
46
|
-
const data = await importMessageBundle(localeId);
|
47
|
-
if (typeof data === "string" && data.endsWith(".json")) {
|
48
|
-
throw new Error(\`[i18n] Invalid bundling detected - dynamic JSON imports bundled as URLs. Switch to inlining JSON files from the build. Check the \"Assets\" documentation for more information.\`);
|
49
|
-
}
|
50
|
-
return data;
|
51
|
-
}
|
52
|
-
|
53
|
-
const localeIds = [${languagesKeysStringArray}];
|
54
|
-
|
55
|
-
localeIds.forEach(localeId => {
|
56
|
-
registerI18nLoader("${packageName}", localeId, importAndCheck);
|
57
|
-
});
|
58
|
-
`;
|
59
67
|
|
68
|
+
contentDynamic = getContent(dynamicImportsString, languagesKeysStringArray, packageName);
|
69
|
+
contentFetchMetaResolve = getContent(fetchMetaResolveString, languagesKeysStringArray, packageName);
|
60
70
|
|
61
71
|
}
|
62
72
|
|
63
73
|
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
64
74
|
return Promise.all([
|
65
75
|
fs.writeFile(outputFileDynamic, contentDynamic),
|
76
|
+
fs.writeFile(outputFileFetchMetaResolve, contentFetchMetaResolve),
|
66
77
|
]);
|
67
78
|
}
|
68
79
|
|
@@ -8,6 +8,7 @@ const ext = isTypeScript ? 'ts' : 'js';
|
|
8
8
|
const generate = async () => {
|
9
9
|
const inputFolder = path.normalize(process.argv[2]);
|
10
10
|
const outputFileDynamic = path.normalize(`${process.argv[3]}/Themes.${ext}`);
|
11
|
+
const outputFileFetchMetaResolve = path.normalize(`${process.argv[3]}/Themes-fetch.${ext}`);
|
11
12
|
|
12
13
|
// All supported optional themes
|
13
14
|
const allThemes = assets.themes.all;
|
@@ -23,14 +24,16 @@ const generate = async () => {
|
|
23
24
|
|
24
25
|
const availableThemesArray = `[${themesOnFileSystem.map(theme => `"${theme}"`).join(", ")}]`;
|
25
26
|
const dynamicImportLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await import(/* webpackChunkName: "${packageName.replace("@", "").replace("/", "-")}-${theme.replace("_", "-")}-parameters-bundle" */"../assets/themes/${theme}/parameters-bundle.css.json")).default;`).join("\n");
|
27
|
+
const fetchMetaResolveLines = themesOnFileSystem.map(theme => `\t\tcase "${theme}": return (await fetch(new URL("../assets/themes/${theme}/parameters-bundle.css.json", import.meta.url))).json();`).join("\n");
|
26
28
|
|
27
29
|
// dynamic imports file content
|
28
|
-
const contentDynamic =
|
30
|
+
const contentDynamic = function (lines) {
|
31
|
+
return `// @ts-nocheck
|
29
32
|
import { registerThemePropertiesLoader } from "@ui5/webcomponents-base/dist/asset-registries/Themes.js";
|
30
33
|
|
31
34
|
const loadThemeProperties = async (themeName) => {
|
32
35
|
switch (themeName) {
|
33
|
-
${
|
36
|
+
${lines}
|
34
37
|
default: throw "unknown theme"
|
35
38
|
}
|
36
39
|
};
|
@@ -46,10 +49,12 @@ const loadAndCheck = async (themeName) => {
|
|
46
49
|
${availableThemesArray}
|
47
50
|
.forEach(themeName => registerThemePropertiesLoader("${packageName}", themeName, loadAndCheck));
|
48
51
|
`;
|
52
|
+
}
|
49
53
|
|
50
54
|
await fs.mkdir(path.dirname(outputFileDynamic), { recursive: true });
|
51
55
|
return Promise.all([
|
52
|
-
fs.writeFile(outputFileDynamic, contentDynamic)
|
56
|
+
fs.writeFile(outputFileDynamic, contentDynamic(dynamicImportLines)),
|
57
|
+
fs.writeFile(outputFileFetchMetaResolve, contentDynamic(fetchMetaResolveLines)),
|
53
58
|
]);
|
54
59
|
};
|
55
60
|
|
@@ -3,11 +3,11 @@ const tsImports = (controlName, hasTypes) => {
|
|
3
3
|
return "";
|
4
4
|
}
|
5
5
|
|
6
|
-
const importPrefix = process.env.UI5_BASE ? "
|
6
|
+
const importPrefix = process.env.UI5_BASE ? "../../../../../src/" : "@ui5/webcomponents-base/dist/"
|
7
7
|
|
8
8
|
return `import type UI5Element from "${importPrefix}UI5Element.js";
|
9
|
-
|
10
|
-
|
9
|
+
${importForControl(controlName, hasTypes)}
|
10
|
+
import type { ClassMapValue } from "${importPrefix}types.js";
|
11
11
|
`;
|
12
12
|
}
|
13
13
|
const importForControl = (controlName, hasTypes) => {
|
@@ -18,13 +18,13 @@ const importForControl = (controlName, hasTypes) => {
|
|
18
18
|
|
19
19
|
if (process.env.UI5_BASE) {
|
20
20
|
// base package has a component in `test/elements` instead of `src`
|
21
|
-
return `import type ${controlName} from "
|
21
|
+
return `import type ${controlName} from "../../../${controlName}.js";`
|
22
22
|
}
|
23
23
|
return `import type ${controlName} from "../../${controlName}.js";`
|
24
24
|
}
|
25
25
|
|
26
26
|
const buildRenderer = (controlName, litTemplate, hasTypes) => {
|
27
|
-
const importPrefix = process.env.UI5_BASE ? "
|
27
|
+
const importPrefix = process.env.UI5_BASE ? "../../../../../src/" : "@ui5/webcomponents-base/dist/"
|
28
28
|
|
29
29
|
// typescript cannot process package imports for the same package and the paths are changed to relative for base package templates
|
30
30
|
return `/* eslint no-unused-vars: 0 */
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ui5/webcomponents-tools",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.2.0-rc.0",
|
4
4
|
"description": "UI5 Web Components: webcomponents.tools",
|
5
5
|
"author": "SAP SE (https://www.sap.com)",
|
6
6
|
"license": "Apache-2.0",
|
@@ -10,6 +10,7 @@
|
|
10
10
|
"sapui5",
|
11
11
|
"ui5"
|
12
12
|
],
|
13
|
+
"types": "./types/index.d.ts",
|
13
14
|
"scripts": {},
|
14
15
|
"bin": {
|
15
16
|
"wc-dev": "bin/dev.js",
|
@@ -84,5 +85,5 @@
|
|
84
85
|
"esbuild": "^0.19.9",
|
85
86
|
"yargs": "^17.5.1"
|
86
87
|
},
|
87
|
-
"gitHead": "
|
88
|
+
"gitHead": "8955aa596143ba93da03d4e6cf2bd547993c59c2"
|
88
89
|
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2021",
|
4
|
+
"lib": [
|
5
|
+
"DOM",
|
6
|
+
"DOM.Iterable",
|
7
|
+
"ES2023"
|
8
|
+
],
|
9
|
+
"declaration": true,
|
10
|
+
"skipLibCheck": true,
|
11
|
+
"sourceMap": true,
|
12
|
+
"inlineSources": true,
|
13
|
+
"strict": true,
|
14
|
+
"moduleResolution": "node"
|
15
|
+
}
|
16
|
+
}
|
package/types/index.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
import "../components-package/cypress/support/component"
|