@breadstone-tools/cem-plugins-custom-js-doc-tags 0.0.12-beta.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.
@@ -0,0 +1,21 @@
1
+ import type { IPlugin } from '@breadstone-tools/cem-plugin';
2
+ export interface IOptions {
3
+ tags?: ICustomTag;
4
+ /** Hides logs produced by the plugin */
5
+ hideLogs?: boolean;
6
+ /** Prevents plugin from executing */
7
+ skip?: boolean;
8
+ }
9
+ export type ICustomTag = Record<string, {
10
+ mappedName?: string;
11
+ isArray?: boolean;
12
+ }>;
13
+ /**
14
+ * CEM Analyzer plugin to expand types in component metadata
15
+ *
16
+ * @param options Configuration options
17
+ *
18
+ * @public
19
+ */
20
+ export declare function customJSDocTagsPlugin(options?: IOptions): IPlugin;
21
+ //# sourceMappingURL=CustomJsDocTagsPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomJsDocTagsPlugin.d.ts","sourceRoot":"","sources":["../src/CustomJsDocTagsPlugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAuB,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAKjF,MAAM,WAAW,QAAQ;IACrB,IAAI,CAAC,EAAE,UAAU,CAAC;IAElB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,qCAAqC;IACrC,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE;IAChC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC,CAAC;AAeP;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,QAAuB,GAAG,OAAO,CAiF/E"}
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ //#region Imports
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.customJSDocTagsPlugin = customJSDocTagsPlugin;
5
+ const comment_parser_1 = require("comment-parser");
6
+ let userOptions = {
7
+ tags: {},
8
+ };
9
+ /**
10
+ * CEM Analyzer plugin to expand types in component metadata
11
+ *
12
+ * @param options Configuration options
13
+ *
14
+ * @public
15
+ */
16
+ function customJSDocTagsPlugin(options = { tags: {} }) {
17
+ userOptions = options;
18
+ return {
19
+ name: 'CUSTOM-JSDOC-TAGS',
20
+ onAnalyze: (params) => {
21
+ // if (params.context.verbose) {
22
+ // params.context.logger.logInfo(' [custom-jsdoc-tags] - Analyzing...');
23
+ // }
24
+ if (params.node.kind !== params.ts.SyntaxKind.ClassDeclaration) {
25
+ return;
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
+ // @ts-ignore
29
+ const className = params.node.name.getText();
30
+ const component = params.moduleDoc.declarations?.find(declaration => declaration.name === className);
31
+ const customTags = Object.keys(userOptions.tags ?? {});
32
+ let customComments = '/**';
33
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
34
+ // @ts-ignore
35
+ params.node.jsDoc?.forEach((jsDoc) => {
36
+ jsDoc?.tags?.forEach((tag) => {
37
+ const tagName = tag.tagName.getText();
38
+ if (customTags.includes(tagName)) {
39
+ customComments += `\n * @${tagName} ${tag.comment}`;
40
+ }
41
+ });
42
+ });
43
+ const parsed = (0, comment_parser_1.parse)(`${customComments}\n */`);
44
+ parsed[0]?.tags?.forEach(tagMeta => {
45
+ const tagOptions = userOptions.tags?.[tagMeta.tag];
46
+ if (!tagOptions) {
47
+ return;
48
+ }
49
+ const propName = tagOptions.mappedName ?? tagMeta.tag;
50
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
51
+ // @ts-ignore
52
+ const existingProp = component[propName];
53
+ const cemTag = {
54
+ name: tagMeta.name === '-' ? '' : tagMeta.name,
55
+ default: tagMeta.default,
56
+ description: tagMeta.description.replace(/^\s?-/, '').trim(), // removes leading dash
57
+ type: tagMeta.type ? { text: tagMeta.type } : undefined,
58
+ };
59
+ if (!existingProp && tagOptions.isArray) {
60
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
61
+ // @ts-ignore
62
+ component[propName] = [cemTag];
63
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
64
+ // @ts-ignore
65
+ }
66
+ else if (Array.isArray(component[propName])) {
67
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
68
+ // @ts-ignore
69
+ component[propName].push(cemTag);
70
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
71
+ // @ts-ignore
72
+ }
73
+ else if (existingProp && !Array.isArray(component[propName])) {
74
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
75
+ // @ts-ignore
76
+ component[propName] = [component[propName], cemTag];
77
+ }
78
+ else {
79
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
80
+ // @ts-ignore
81
+ component[propName] = cemTag;
82
+ }
83
+ });
84
+ // if (!options.hideLogs) {
85
+ // Logger.instance().logInfo('[custom-jsdoc-tags] - Custom Elements Manifest updated.');
86
+ // }
87
+ },
88
+ };
89
+ }
90
+ //# sourceMappingURL=CustomJsDocTagsPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomJsDocTagsPlugin.js","sourceRoot":"","sources":["../src/CustomJsDocTagsPlugin.ts"],"names":[],"mappings":";AAAA,iBAAiB;;AA0CjB,sDAiFC;AAxHD,mDAAuC;AA4BvC,IAAI,WAAW,GAAa;IACxB,IAAI,EAAE,EAAE;CACX,CAAC;AAEF;;;;;;GAMG;AACH,SAAgB,qBAAqB,CAAC,UAAoB,EAAE,IAAI,EAAE,EAAE,EAAE;IAClE,WAAW,GAAG,OAAO,CAAC;IAEtB,OAAO;QACH,IAAI,EAAE,mBAAmB;QACzB,SAAS,EAAE,CAAC,MAA2B,EAAE,EAAE;YACvC,gCAAgC;YAChC,iFAAiF;YACjF,IAAI;YAEJ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,EAAE,CAAC,UAAU,CAA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AAG,MAAM,CAAC;gBACjC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,2BAA2B;YAC3B,4FAA4F;YAC5F,IAAI;QACR,CAAC;KACJ,CAAC;AACN,CAAC"}
package/Index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export type { IOptions } from './CustomJsDocTagsPlugin.js';
2
+ export { customJSDocTagsPlugin } from './CustomJsDocTagsPlugin.js';
3
+ //# sourceMappingURL=Index.d.ts.map
package/Index.d.ts.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.d.ts","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
package/Index.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customJSDocTagsPlugin = void 0;
4
+ var CustomJsDocTagsPlugin_js_1 = require("./CustomJsDocTagsPlugin.js");
5
+ Object.defineProperty(exports, "customJSDocTagsPlugin", { enumerable: true, get: function () { return CustomJsDocTagsPlugin_js_1.customJSDocTagsPlugin; } });
6
+ //# sourceMappingURL=Index.js.map
package/Index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Index.js","sourceRoot":"","sources":["../src/Index.ts"],"names":[],"mappings":";;;AACA,uEAAmE;AAA1D,iIAAA,qBAAqB,OAAA"}
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Breadstone
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "@breadstone-tools/cem-plugins-custom-js-doc-tags",
3
+ "description": "Custom Elements Manifest Plugin for parsing custom JSDoc tags",
4
+ "version": "0.0.12-beta.0",
5
+ "license": "MIT",
6
+ "author": "andre.wehlert <awehlert@breadstone.de> (https://www.breadstone.de)",
7
+ "repository": {
8
+ "url": "git+ssh://git@github.com/RueDeRennes/mosaik.git"
9
+ },
10
+ "type": "commonjs",
11
+ "main": "./Index.js",
12
+ "commonjs": "./Index.js",
13
+ "module": "./Index.js",
14
+ "types": "./Index.d.ts",
15
+ "dependencies": {
16
+ "@breadstone-infrastructure/utilities": "^0.0.12-beta.0",
17
+ "@breadstone-tools/cem-infrastructure": "^0.0.12-beta.0",
18
+ "@breadstone-tools/cem-plugin": "^0.0.12-beta.0",
19
+ "comment-parser": "^1.4.1"
20
+ }
21
+ }