@ui5/webcomponents-tools 0.0.0-4821618b2 → 0.0.0-49bade48d
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 +2549 -0
- package/LICENSE.txt +201 -0
- package/README.md +7 -10
- package/assets-meta.js +16 -7
- package/bin/dev.js +10 -8
- package/bin/ui5nps.js +301 -0
- package/components-package/eslint.js +67 -3
- package/components-package/nps.js +156 -77
- package/components-package/postcss.components.js +1 -21
- package/components-package/postcss.themes.js +1 -23
- package/components-package/vite.config.js +9 -0
- package/components-package/wdio.js +116 -39
- package/icons-collection/nps.js +60 -18
- package/lib/amd-to-es6/index.js +109 -0
- package/lib/amd-to-es6/no-remaining-require.js +33 -0
- package/lib/cem/cem.js +16 -0
- package/lib/cem/custom-elements-manifest.config.mjs +614 -0
- package/lib/cem/event.mjs +168 -0
- package/lib/cem/merge.mjs +220 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/cli.js +128 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/package.json +59 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/browser-entrypoint.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/create.js +117 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/arrow-function.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/class-jsdoc.js +157 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/classes.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createArrowFunction.js +17 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createAttribute.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClass.js +301 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createClassField.js +26 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createFunctionLike.js +73 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createMixin.js +33 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/createVariable.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/creators/handlers.js +338 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/custom-elements-define-calls.js +90 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js +156 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js +24 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/mixins.js +29 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/reexported-wrapped-mixin-exports.js +84 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/collect-phase/collect-imports.js +101 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/catalyst.js +11 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/catalyst-major-2/controller.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/attr.js +53 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/decorators/custom-element-decorator.js +36 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/fast/fast.js +7 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js +13 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/member-denylist.js +21 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/method-denylist.js +20 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/property-decorator.js +94 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/static-properties.js +121 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/utils.js +66 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/stencil/stencil.js +129 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/index.js +80 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/cleanup-classes.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/field-denylist.js +22 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/link-phase/method-denylist.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/apply-inheritance.js +78 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/is-custom-element.js +34 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/link-class-to-tagname.js +27 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/remove-unexported-declarations.js +23 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/post-processing/resolve-initializers.js +52 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/ast-helpers.js +186 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/cli-helpers.js +164 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/exports.js +44 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/find-external-manifests.js +67 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/imports.js +25 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/index.js +71 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/jsdoc.js +19 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/manifest-helpers.js +194 -0
- package/lib/cem/patch/@custom-elements-manifest/analyzer/src/utils/mixins.js +112 -0
- package/lib/cem/schema-internal.json +1462 -0
- package/lib/cem/schema.json +1138 -0
- package/lib/cem/types-internal.d.ts +838 -0
- package/lib/cem/types.d.ts +766 -0
- package/lib/cem/utils.mjs +433 -0
- package/lib/cem/validate.js +81 -0
- package/lib/chokidar/chokidar.js +28 -0
- package/lib/copy-and-watch/index.js +133 -97
- package/lib/copy-list/index.js +27 -19
- package/lib/create-icons/index.js +136 -58
- package/lib/create-illustrations/index.js +246 -0
- 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 +66 -97
- package/lib/css-processors/css-processor-components.mjs +103 -0
- package/lib/css-processors/css-processor-themes.mjs +226 -0
- package/lib/css-processors/merge-light-dark.mjs +131 -0
- package/lib/css-processors/postcss-plugin.mjs +153 -0
- package/lib/css-processors/scope-variables.mjs +74 -0
- package/lib/css-processors/shared.mjs +47 -0
- package/lib/dev-server/custom-hot-update-plugin.js +39 -0
- package/lib/dev-server/dev-server.mjs +78 -0
- package/lib/dev-server/virtual-index-html-plugin.js +56 -0
- package/lib/eslint/eslint.js +44 -0
- package/lib/generate-js-imports/illustrations.js +87 -0
- package/lib/generate-json-imports/i18n.js +71 -69
- package/lib/generate-json-imports/themes.js +50 -48
- package/lib/hbs2lit/src/compiler.js +24 -4
- package/lib/hbs2lit/src/includesReplacer.js +5 -5
- package/lib/hbs2lit/src/litVisitor2.js +95 -24
- package/lib/hbs2lit/src/svgProcessor.js +12 -5
- package/lib/hbs2ui5/RenderTemplates/LitRenderer.js +38 -11
- package/lib/hbs2ui5/index.js +57 -24
- package/lib/i18n/defaults.js +76 -60
- package/lib/i18n/toJSON.js +47 -18
- package/lib/icons-hash/icons-hash.mjs +149 -0
- package/lib/postcss-combine-duplicated-selectors/index.js +185 -0
- package/lib/remove-dev-mode/remove-dev-mode.mjs +51 -0
- package/lib/rimraf/rimraf.js +31 -0
- package/lib/scoping/get-all-tags.js +11 -11
- package/lib/scoping/lint-src.js +9 -8
- 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 +79 -0
- package/lib/vite-bundler/vite-bundler.mjs +35 -0
- package/package.json +52 -52
- package/tsconfig.json +18 -0
- package/bin/init-ui5-package.js +0 -3
- package/components-package/rollup.js +0 -197
- 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/init-package/index.js +0 -136
- package/lib/init-package/resources/.eslintignore +0 -3
- package/lib/init-package/resources/bundle.es5.js +0 -25
- package/lib/init-package/resources/bundle.esm.js +0 -31
- package/lib/init-package/resources/config/.eslintrc.js +0 -1
- package/lib/init-package/resources/config/postcss.components/postcss.config.js +0 -1
- package/lib/init-package/resources/config/postcss.themes/postcss.config.js +0 -1
- package/lib/init-package/resources/config/rollup.config.js +0 -1
- package/lib/init-package/resources/config/wdio.conf.js +0 -1
- package/lib/init-package/resources/package-scripts.js +0 -11
- package/lib/init-package/resources/src/Assets.js +0 -5
- package/lib/init-package/resources/src/MyFirstComponent.hbs +0 -1
- package/lib/init-package/resources/src/MyFirstComponent.js +0 -56
- package/lib/init-package/resources/src/i18n/messagebundle.properties +0 -2
- package/lib/init-package/resources/src/i18n/messagebundle_de.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_en.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_es.properties +0 -1
- package/lib/init-package/resources/src/i18n/messagebundle_fr.properties +0 -1
- package/lib/init-package/resources/src/themes/MyFirstComponent.css +0 -11
- package/lib/init-package/resources/src/themes/sap_belize/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_belize_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_dark/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcb/parameters-bundle.css +0 -3
- package/lib/init-package/resources/src/themes/sap_fiori_3_hcw/parameters-bundle.css +0 -3
- package/lib/init-package/resources/test/pages/index.html +0 -56
- package/lib/init-package/resources/test/specs/Demo.spec.js +0 -12
- 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 -31
- 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
package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/exports.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { getDeclarationInFile, hasIgnoreJSDoc } from '../../utils/ast-helpers.js';
|
|
2
|
+
import {
|
|
3
|
+
hasExportModifier,
|
|
4
|
+
hasDefaultModifier,
|
|
5
|
+
hasNamedExports,
|
|
6
|
+
isReexport,
|
|
7
|
+
} from '../../utils/exports.js';
|
|
8
|
+
import { isBareModuleSpecifier } from '../../utils/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* EXPORTS
|
|
12
|
+
*
|
|
13
|
+
* Analyzes a modules exports and adds them to the moduleDoc
|
|
14
|
+
*/
|
|
15
|
+
export function exportsPlugin() {
|
|
16
|
+
return {
|
|
17
|
+
name: 'CORE - EXPORTS',
|
|
18
|
+
analyzePhase({ts, node, moduleDoc}){
|
|
19
|
+
if(hasIgnoreJSDoc(node)) return;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @example export const foo = '';
|
|
23
|
+
*/
|
|
24
|
+
if(hasExportModifier(node) && ts.isVariableStatement(node)) {
|
|
25
|
+
node?.declarationList?.declarations?.forEach(declaration => {
|
|
26
|
+
const _export = {
|
|
27
|
+
kind: 'js',
|
|
28
|
+
name: declaration.name.getText(),
|
|
29
|
+
declaration: {
|
|
30
|
+
name: declaration.name.getText(),
|
|
31
|
+
module: moduleDoc.path,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @example export default var1;
|
|
41
|
+
*/
|
|
42
|
+
if (node.kind === ts.SyntaxKind.ExportAssignment) {
|
|
43
|
+
const _export = {
|
|
44
|
+
kind: 'js',
|
|
45
|
+
name: 'default',
|
|
46
|
+
declaration: {
|
|
47
|
+
name: node.expression.text,
|
|
48
|
+
module: moduleDoc.path,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (node.kind === ts.SyntaxKind.ExportDeclaration) {
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @example export { var1, var2 };
|
|
58
|
+
*/
|
|
59
|
+
if (hasNamedExports(node) && !isReexport(node)) {
|
|
60
|
+
node.exportClause?.elements?.forEach((element) => {
|
|
61
|
+
if (hasIgnoreJSDoc(element) || hasIgnoreJSDoc(getDeclarationInFile(element, node.getSourceFile())))
|
|
62
|
+
return;
|
|
63
|
+
|
|
64
|
+
const _export = {
|
|
65
|
+
kind: 'js',
|
|
66
|
+
name: element.name.getText(),
|
|
67
|
+
declaration: {
|
|
68
|
+
name: element.propertyName?.getText() || element.name.getText(),
|
|
69
|
+
module: moduleDoc.path,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* @example export * from 'foo';
|
|
79
|
+
* @example export * from './my-module.js';
|
|
80
|
+
*/
|
|
81
|
+
if (isReexport(node) && !hasNamedExports(node)) {
|
|
82
|
+
const _export = {
|
|
83
|
+
kind: 'js',
|
|
84
|
+
name: '*',
|
|
85
|
+
declaration: {
|
|
86
|
+
name: '*',
|
|
87
|
+
package: node.moduleSpecifier.getText().replace(/'/g, ''),
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @example export { var1, var2 } from 'foo';
|
|
95
|
+
* @example export { var1, var2 } from './my-module.js';
|
|
96
|
+
*/
|
|
97
|
+
if (isReexport(node) && hasNamedExports(node)) {
|
|
98
|
+
node.exportClause?.elements?.forEach((element) => {
|
|
99
|
+
const _export = {
|
|
100
|
+
kind: 'js',
|
|
101
|
+
name: element.name.getText(),
|
|
102
|
+
declaration: {
|
|
103
|
+
name: element.propertyName?.getText() || element.name.getText(),
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
if (isBareModuleSpecifier(node.moduleSpecifier.getText())) {
|
|
108
|
+
_export.declaration.package = node.moduleSpecifier.getText().replace(/'/g, '');
|
|
109
|
+
} else {
|
|
110
|
+
_export.declaration.module = node.moduleSpecifier.getText().replace(/'/g, '');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* @example export function foo() {}
|
|
120
|
+
*/
|
|
121
|
+
if (node.kind === ts.SyntaxKind.FunctionDeclaration) {
|
|
122
|
+
if (hasExportModifier(node)) {
|
|
123
|
+
const isDefault = hasDefaultModifier(node);
|
|
124
|
+
const _export = {
|
|
125
|
+
kind: 'js',
|
|
126
|
+
name: isDefault ? 'default' : node.name?.getText() || '',
|
|
127
|
+
declaration: {
|
|
128
|
+
name: node.name?.getText() || '',
|
|
129
|
+
module: moduleDoc.path,
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* @example export class Class1 {}
|
|
139
|
+
*/
|
|
140
|
+
if (node.kind === ts.SyntaxKind.ClassDeclaration) {
|
|
141
|
+
if (hasExportModifier(node)) {
|
|
142
|
+
const isDefault = hasDefaultModifier(node);
|
|
143
|
+
const _export = {
|
|
144
|
+
kind: 'js',
|
|
145
|
+
name: isDefault ? 'default' : node?.name?.text || '',
|
|
146
|
+
declaration: {
|
|
147
|
+
name: node?.name?.text || '',
|
|
148
|
+
module: moduleDoc.path,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), _export];
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/function-like.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createFunctionLike } from './creators/createFunctionLike.js';
|
|
2
|
+
import { isMixin } from '../../utils/mixins.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* functionLikePlugin
|
|
6
|
+
*
|
|
7
|
+
* handles functionLikes such as class methods and functions
|
|
8
|
+
* does NOT handle arrow functions
|
|
9
|
+
*/
|
|
10
|
+
export function functionLikePlugin() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'CORE - FUNCTION-LIKE',
|
|
13
|
+
analyzePhase({ts, node, moduleDoc}){
|
|
14
|
+
switch(node.kind) {
|
|
15
|
+
case ts.SyntaxKind.FunctionDeclaration:
|
|
16
|
+
if(!isMixin(node)) {
|
|
17
|
+
const functionLike = createFunctionLike(node);
|
|
18
|
+
moduleDoc.declarations.push(functionLike);
|
|
19
|
+
}
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { extractMixinNodes, isMixin } from '../../utils/mixins.js';
|
|
2
|
+
import { createMixin } from './creators/createMixin.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* mixinPlugin
|
|
6
|
+
*
|
|
7
|
+
* handles mixins
|
|
8
|
+
*/
|
|
9
|
+
export function mixinPlugin() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'CORE - MIXINS',
|
|
12
|
+
analyzePhase({ts, node, moduleDoc, context}){
|
|
13
|
+
switch(node.kind) {
|
|
14
|
+
case ts.SyntaxKind.VariableStatement:
|
|
15
|
+
case ts.SyntaxKind.FunctionDeclaration:
|
|
16
|
+
/**
|
|
17
|
+
* Try to extract mixin nodes, if its a mixin
|
|
18
|
+
*/
|
|
19
|
+
if(isMixin(node)) {
|
|
20
|
+
const { mixinFunction, mixinClass } = extractMixinNodes(node);
|
|
21
|
+
let mixin = createMixin(mixinFunction, mixinClass, moduleDoc, context);
|
|
22
|
+
moduleDoc.declarations.push(mixin);
|
|
23
|
+
}
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { isMixin } from '../../utils/mixins.js';
|
|
2
|
+
import { has } from '../../utils/index.js';
|
|
3
|
+
import { createClassDeclarationMixin } from './creators/handlers.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* REEXPORTED WRAPPED MIXIN EXPORTS
|
|
7
|
+
*
|
|
8
|
+
* Handle exported mixins
|
|
9
|
+
* @example ```
|
|
10
|
+
*
|
|
11
|
+
* function FooMixinImpl(klass) {
|
|
12
|
+
* class FooMixin extends klass {}
|
|
13
|
+
* return FooMixin;
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* export const FooMixin = dedupeMixin(FooMixinImpl);
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export function reexportedWrappedMixinExportsPlugin() {
|
|
21
|
+
return {
|
|
22
|
+
name: 'CORE - REEXPORTED-WRAPPED-MIXINS',
|
|
23
|
+
analyzePhase({ts, node, moduleDoc, context}){
|
|
24
|
+
switch(node.kind) {
|
|
25
|
+
case ts.SyntaxKind.VariableStatement:
|
|
26
|
+
if(!isMixin(node)) {
|
|
27
|
+
node?.declarationList?.declarations?.forEach(declaration => {
|
|
28
|
+
|
|
29
|
+
const mixins = [];
|
|
30
|
+
if(ts.SyntaxKind.CallExpression === declaration?.initializer?.kind) {
|
|
31
|
+
/**
|
|
32
|
+
* If an exported variable has a callExpression, it might try to export a mixin
|
|
33
|
+
* We need to check if the current module contains any mixins
|
|
34
|
+
*/
|
|
35
|
+
const moduleMixinDeclarations = moduleDoc?.declarations?.filter(declaration => declaration.kind === 'mixin');
|
|
36
|
+
|
|
37
|
+
if(has(moduleMixinDeclarations)){
|
|
38
|
+
const mixinName = declaration?.initializer?.expression?.getText();
|
|
39
|
+
mixins.push(mixinName);
|
|
40
|
+
|
|
41
|
+
let node = declaration?.initializer?.arguments[0];
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Handle nested Mixin calls
|
|
45
|
+
*/
|
|
46
|
+
while(node && ts.isCallExpression(node)) {
|
|
47
|
+
const mixinName = node.expression.getText();
|
|
48
|
+
mixins.push(mixinName);
|
|
49
|
+
|
|
50
|
+
node = node?.arguments[0]
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* See if we can find the supposed Mixin in the modules declaration
|
|
55
|
+
* If we do, change the name of MixinImpl to the variableDeclaration thats actually being exported
|
|
56
|
+
*/
|
|
57
|
+
const foundMixin = moduleMixinDeclarations?.find(mixin => mixin.name === node?.getText());
|
|
58
|
+
if(foundMixin) {
|
|
59
|
+
foundMixin.name = declaration?.name?.getText()
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Next, we need to add any other mixins found along the way to the exported mixin's `mixins` array
|
|
63
|
+
*/
|
|
64
|
+
mixins?.forEach(mixin => {
|
|
65
|
+
const newMixin = createClassDeclarationMixin(mixin, moduleDoc, context);
|
|
66
|
+
foundMixin.mixins = [...(foundMixin?.mixins || []), newMixin];
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* At this point, there's now a variable declaration and a mixin declaration with the same name.
|
|
71
|
+
* We're only interested in the mixin, so we filter out the variable declaration
|
|
72
|
+
*/
|
|
73
|
+
moduleDoc.declarations = moduleDoc?.declarations?.filter(declaration => !(declaration.kind === 'variable' && declaration.name === foundMixin.name));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/analyse-phase/variables.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createVariable } from './creators/createVariable.js';
|
|
2
|
+
import { isMixin } from '../../utils/mixins.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* variablePlugin
|
|
6
|
+
*
|
|
7
|
+
* handles variables
|
|
8
|
+
*/
|
|
9
|
+
export function variablePlugin() {
|
|
10
|
+
return {
|
|
11
|
+
name: 'CORE - VARIABLES',
|
|
12
|
+
analyzePhase({ts, node, moduleDoc}){
|
|
13
|
+
switch(node.kind) {
|
|
14
|
+
case ts.SyntaxKind.VariableStatement:
|
|
15
|
+
if(!isMixin(node)) {
|
|
16
|
+
node?.declarationList?.declarations?.forEach(declaration => {
|
|
17
|
+
/**
|
|
18
|
+
* It can be the case that a variable is already present in the declarations,
|
|
19
|
+
* for example if the variable is also an arrow function. So we need to make sure
|
|
20
|
+
* the declaration doesnt already exist before adding it to a modules declarations
|
|
21
|
+
*/
|
|
22
|
+
const alreadyExists = moduleDoc?.declarations?.some(_declaration => _declaration.name === declaration?.name?.getText());
|
|
23
|
+
|
|
24
|
+
if(!alreadyExists) {
|
|
25
|
+
const variable = createVariable(node, declaration);
|
|
26
|
+
moduleDoc.declarations.push(variable);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasDefaultImport,
|
|
3
|
+
hasNamedImport,
|
|
4
|
+
hasAggregatingImport,
|
|
5
|
+
hasSideEffectImport,
|
|
6
|
+
} from '../../utils/imports.js';
|
|
7
|
+
import { isBareModuleSpecifier } from '../../utils/index.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* COLLECT-IMPORTS
|
|
11
|
+
*
|
|
12
|
+
* Collects a modules imports so that declarations can later be resolved to their module/package.
|
|
13
|
+
*/
|
|
14
|
+
export function collectImportsPlugin() {
|
|
15
|
+
const files = {};
|
|
16
|
+
let currModuleImports;
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
name: 'CORE - IMPORTS',
|
|
20
|
+
collectPhase({ts, node}) {
|
|
21
|
+
if(node.kind === ts.SyntaxKind.SourceFile) {
|
|
22
|
+
/**
|
|
23
|
+
* Create an empty array for each module we visit
|
|
24
|
+
*/
|
|
25
|
+
files[node.fileName] = [];
|
|
26
|
+
currModuleImports = files[node.fileName];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @example import defaultExport from 'foo';
|
|
31
|
+
*/
|
|
32
|
+
if (hasDefaultImport(node)) {
|
|
33
|
+
const importTemplate = {
|
|
34
|
+
name: node.importClause.name.text,
|
|
35
|
+
kind: 'default',
|
|
36
|
+
importPath: node.moduleSpecifier.text,
|
|
37
|
+
isBareModuleSpecifier: isBareModuleSpecifier(node.moduleSpecifier.text),
|
|
38
|
+
isTypeOnly: !!node?.importClause?.isTypeOnly
|
|
39
|
+
};
|
|
40
|
+
currModuleImports.push(importTemplate);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @example import { export1, export2 } from 'foo';
|
|
45
|
+
* @example import { export1 as alias1 } from 'foo';
|
|
46
|
+
* @example import { export1, export2 as alias2 } from 'foo';
|
|
47
|
+
*/
|
|
48
|
+
if (hasNamedImport(node)) {
|
|
49
|
+
node.importClause.namedBindings.elements.forEach((element) => {
|
|
50
|
+
const importTemplate = {
|
|
51
|
+
name: element.name.text,
|
|
52
|
+
kind: 'named',
|
|
53
|
+
importPath: node.moduleSpecifier.text,
|
|
54
|
+
isBareModuleSpecifier: isBareModuleSpecifier(node.moduleSpecifier.text),
|
|
55
|
+
isTypeOnly: !!node?.importClause?.isTypeOnly
|
|
56
|
+
};
|
|
57
|
+
currModuleImports.push(importTemplate);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @example import * as name from './my-module.js';
|
|
63
|
+
*/
|
|
64
|
+
if (hasAggregatingImport(node)) {
|
|
65
|
+
const importTemplate = {
|
|
66
|
+
name: node.importClause.namedBindings.name.text,
|
|
67
|
+
kind: 'aggregate',
|
|
68
|
+
importPath: node.moduleSpecifier.text,
|
|
69
|
+
isBareModuleSpecifier: isBareModuleSpecifier(node.moduleSpecifier.text),
|
|
70
|
+
isTypeOnly: !!node?.importClause?.isTypeOnly
|
|
71
|
+
};
|
|
72
|
+
currModuleImports.push(importTemplate);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @example import './my-module.js';
|
|
77
|
+
*/
|
|
78
|
+
if(hasSideEffectImport(node)) {
|
|
79
|
+
const importTemplate = {
|
|
80
|
+
kind: 'side-effect',
|
|
81
|
+
importPath: node.moduleSpecifier.text,
|
|
82
|
+
isBareModuleSpecifier: isBareModuleSpecifier(node.moduleSpecifier.text),
|
|
83
|
+
isTypeOnly: false
|
|
84
|
+
};
|
|
85
|
+
currModuleImports.push(importTemplate);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
analyzePhase({ts, node, context}) {
|
|
89
|
+
if(node.kind === ts.SyntaxKind.SourceFile) {
|
|
90
|
+
|
|
91
|
+
/** Makes the imports available on the context object for a given module */
|
|
92
|
+
context.imports = files[node.fileName];
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
packageLinkPhase({context}) {
|
|
96
|
+
/** Reset */
|
|
97
|
+
context.imports = [];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { dasherize } from '@github/catalyst/lib/dasherize.js';
|
|
2
|
+
import { attrDecoratorPlugin } from '../decorators/attr.js';
|
|
3
|
+
import { controllerPlugin } from './controller.js';
|
|
4
|
+
|
|
5
|
+
export const catalystPlugin = () => [
|
|
6
|
+
attrDecoratorPlugin(attr => {
|
|
7
|
+
attr.name = `data-${dasherize(attr.name)}`;
|
|
8
|
+
return attr;
|
|
9
|
+
}),
|
|
10
|
+
controllerPlugin()
|
|
11
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { toKebabCase, resolveModuleOrPackageSpecifier, decorator } from '../../../utils/index.js'
|
|
2
|
+
|
|
3
|
+
export function controllerPlugin() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'CORE - CONTROLLER',
|
|
6
|
+
analyzePhase({ts, node, moduleDoc, context}){
|
|
7
|
+
switch(node.kind) {
|
|
8
|
+
case ts.SyntaxKind.ClassDeclaration:
|
|
9
|
+
/**
|
|
10
|
+
* handle @controller
|
|
11
|
+
*/
|
|
12
|
+
const hasController = node?.modifiers?.find(decorator('controller'));
|
|
13
|
+
|
|
14
|
+
if(hasController) {
|
|
15
|
+
const className = node?.name?.getText();
|
|
16
|
+
|
|
17
|
+
const definitionDoc = {
|
|
18
|
+
kind: 'custom-element-definition',
|
|
19
|
+
name: toKebabCase(className).replace('-element', ''),
|
|
20
|
+
declaration: {
|
|
21
|
+
name: className,
|
|
22
|
+
...resolveModuleOrPackageSpecifier(moduleDoc, context, className)
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
moduleDoc.exports.push(definitionDoc);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { dasherize } from '@github/catalyst/lib/dasherize.js';
|
|
2
|
+
import { attrDecoratorPlugin } from '../decorators/attr.js';
|
|
3
|
+
import { controllerPlugin } from './controller.js';
|
|
4
|
+
|
|
5
|
+
export const catalystPlugin2 = () => [
|
|
6
|
+
attrDecoratorPlugin(attr => {
|
|
7
|
+
attr.name = dasherize(attr.name);
|
|
8
|
+
return attr;
|
|
9
|
+
}),
|
|
10
|
+
controllerPlugin()
|
|
11
|
+
]
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { toKebabCase, resolveModuleOrPackageSpecifier, decorator } from '../../../utils/index.js'
|
|
2
|
+
|
|
3
|
+
export function controllerPlugin() {
|
|
4
|
+
return {
|
|
5
|
+
name: 'CORE - CONTROLLER',
|
|
6
|
+
analyzePhase({ts, node, moduleDoc, context}){
|
|
7
|
+
switch(node.kind) {
|
|
8
|
+
case ts.SyntaxKind.ClassDeclaration:
|
|
9
|
+
/**
|
|
10
|
+
* handle @controller
|
|
11
|
+
*/
|
|
12
|
+
const hasController = node?.modifiers?.find(decorator('controller'));
|
|
13
|
+
|
|
14
|
+
if(hasController) {
|
|
15
|
+
const className = node?.name?.getText();
|
|
16
|
+
|
|
17
|
+
const definitionDoc = {
|
|
18
|
+
kind: 'custom-element-definition',
|
|
19
|
+
name: toKebabCase(className).replace('-element', ''),
|
|
20
|
+
declaration: {
|
|
21
|
+
name: className,
|
|
22
|
+
...resolveModuleOrPackageSpecifier(moduleDoc, context, className)
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
moduleDoc.exports.push(definitionDoc);
|
|
28
|
+
}
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { decorator } from '../../../utils/index.js'
|
|
2
|
+
import { getOptionsObject } from '../../../utils/ast-helpers.js'
|
|
3
|
+
import { createAttributeFromField } from '../../analyse-phase/creators/createAttribute.js';
|
|
4
|
+
|
|
5
|
+
export function attrDecoratorPlugin(converter) {
|
|
6
|
+
return {
|
|
7
|
+
name: 'CORE - ATTR-DECORATOR',
|
|
8
|
+
analyzePhase({ts, node, moduleDoc}){
|
|
9
|
+
switch(node.kind) {
|
|
10
|
+
case ts.SyntaxKind.ClassDeclaration:
|
|
11
|
+
const className = node?.name?.getText();
|
|
12
|
+
const classDoc = moduleDoc?.declarations?.find(declaration => declaration.name === className);
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* If a field has the @attr decorator, create an attr from the field in the classDoc
|
|
16
|
+
*/
|
|
17
|
+
node?.members?.forEach(member => {
|
|
18
|
+
const hasAttrDecorator = member?.modifiers?.find(decorator('attr'));
|
|
19
|
+
if(hasAttrDecorator) {
|
|
20
|
+
const correspondingField = classDoc?.members?.find(classMember => classMember.name === member.name.getText());
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* If a `field` was not found on the `currClass`, that's because it has a @internal jsdoc notation
|
|
24
|
+
*/
|
|
25
|
+
if(!correspondingField) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let attribute = createAttributeFromField(correspondingField);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An @attr might have an options object, like: @attr({attribute: 'my-el'})
|
|
33
|
+
* to specify the attribute name, here we check if it does have such an object
|
|
34
|
+
* and add the name to the attribute
|
|
35
|
+
*/
|
|
36
|
+
const optionsObject = getOptionsObject(hasAttrDecorator);
|
|
37
|
+
if(optionsObject) {
|
|
38
|
+
const name = optionsObject?.properties?.find(prop => prop.name.getText() === 'attribute')?.initializer?.text;
|
|
39
|
+
attribute.name = name;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (converter) {
|
|
43
|
+
attribute = converter(attribute);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
classDoc.attributes = [...(classDoc.attributes || []), attribute];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { getElementNameFromDecorator } from '../../../utils/ast-helpers.js';
|
|
2
|
+
import { has, decorator, resolveModuleOrPackageSpecifier } from '../../../utils/index.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* CUSTOMELEMENT
|
|
6
|
+
*
|
|
7
|
+
* Handles the customElement decorator
|
|
8
|
+
* @example @customElement('my-el');
|
|
9
|
+
*/
|
|
10
|
+
export function customElementDecoratorPlugin() {
|
|
11
|
+
return {
|
|
12
|
+
name: 'CORE - CUSTOM-ELEMENT-DECORATOR',
|
|
13
|
+
analyzePhase({node, moduleDoc, context}){
|
|
14
|
+
if (has(node.modifiers)) {
|
|
15
|
+
const customElementDecorator = node.modifiers?.find(decorator('customElement'));
|
|
16
|
+
|
|
17
|
+
if(customElementDecorator) {
|
|
18
|
+
const className = node.name.text;
|
|
19
|
+
const tagName = getElementNameFromDecorator(customElementDecorator);
|
|
20
|
+
|
|
21
|
+
const definitionDoc = {
|
|
22
|
+
kind: 'custom-element-definition',
|
|
23
|
+
name: tagName,
|
|
24
|
+
declaration: {
|
|
25
|
+
name: className,
|
|
26
|
+
...resolveModuleOrPackageSpecifier(moduleDoc, context, className)
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
moduleDoc.exports = [...(moduleDoc.exports || []), definitionDoc];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
package/lib/cem/patch/@custom-elements-manifest/analyzer/src/features/framework-plugins/lit/lit.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { customElementDecoratorPlugin } from '../decorators/custom-element-decorator.js';
|
|
2
|
+
import { methodDenyListPlugin } from './method-denylist.js';
|
|
3
|
+
import { memberDenyListPlugin } from './member-denylist.js';
|
|
4
|
+
import { propertyDecoratorPlugin } from './property-decorator.js';
|
|
5
|
+
import { staticPropertiesPlugin } from './static-properties.js';
|
|
6
|
+
|
|
7
|
+
export const litPlugin = () => [
|
|
8
|
+
customElementDecoratorPlugin(),
|
|
9
|
+
methodDenyListPlugin(),
|
|
10
|
+
memberDenyListPlugin(),
|
|
11
|
+
propertyDecoratorPlugin(),
|
|
12
|
+
staticPropertiesPlugin()
|
|
13
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MEMBER-DENY-LIST
|
|
3
|
+
*
|
|
4
|
+
* Excludes members from the manifest
|
|
5
|
+
*/
|
|
6
|
+
export function memberDenyListPlugin() {
|
|
7
|
+
const MEMBER_DENY_LIST = ['properties', 'styles'];
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
name: 'CORE - LIT-MEMBER-DENYLIST',
|
|
11
|
+
moduleLinkPhase({moduleDoc}){
|
|
12
|
+
const classes = moduleDoc?.declarations?.filter(declaration => declaration.kind === 'class');
|
|
13
|
+
|
|
14
|
+
classes?.forEach(klass => {
|
|
15
|
+
if(!klass?.members) return;
|
|
16
|
+
klass.members = klass?.members?.filter(member => !MEMBER_DENY_LIST.includes(member.name));
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* METHOD-DENY-LIST
|
|
3
|
+
*
|
|
4
|
+
* Excludes methods from the manifest
|
|
5
|
+
*/
|
|
6
|
+
export function methodDenyListPlugin() {
|
|
7
|
+
const METHOD_DENY_LIST = ['requestUpdate', 'createRenderRoot', 'scheduleUpdate', 'performUpdate', 'shouldUpdate', 'update', 'render', 'firstUpdated', 'updated', 'willUpdate'];
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
name: 'CORE - LIT-METHOD-DENYLIST',
|
|
11
|
+
moduleLinkPhase({moduleDoc}){
|
|
12
|
+
const classesAndMixins = moduleDoc?.declarations?.filter(declaration => declaration.kind === 'class' || declaration.kind === 'mixin');
|
|
13
|
+
|
|
14
|
+
classesAndMixins?.forEach(klass => {
|
|
15
|
+
if(!klass?.members) return;
|
|
16
|
+
klass.members = klass?.members?.filter(member => !METHOD_DENY_LIST.includes(member.name));
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
}
|
|
20
|
+
}
|