@htmlplus/element 0.4.4 → 0.4.7
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/bundler/index.d.ts +2 -0
- package/bundler/index.js +2 -0
- package/bundler/rollup.d.ts +7 -0
- package/bundler/rollup.js +21 -0
- package/bundler/vite.d.ts +7 -0
- package/bundler/vite.js +25 -0
- package/client/decorators/attributes.d.ts +1 -1
- package/client/decorators/element.d.ts +1 -1
- package/client/decorators/event.d.ts +1 -1
- package/client/decorators/listen.d.ts +1 -1
- package/client/decorators/method.d.ts +1 -1
- package/client/decorators/property.d.ts +1 -1
- package/client/decorators/state.d.ts +1 -1
- package/client/decorators/watch.d.ts +1 -1
- package/client/helpers/direction.d.ts +1 -1
- package/client/helpers/isRTL.d.ts +1 -1
- package/client/helpers/slots.d.ts +1 -1
- package/client/utils/getMemberType.d.ts +1 -1
- package/client/utils/getMembersKey.d.ts +1 -1
- package/client/utils/getStyles.d.ts +1 -1
- package/client/utils/host.d.ts +1 -1
- package/client/utils/request.d.ts +1 -1
- package/client/utils/request.js +2 -2
- package/compiler/compiler.d.ts +1 -1
- package/compiler/plugins/{external.d.ts → assets.d.ts} +4 -4
- package/compiler/plugins/assets.js +26 -0
- package/compiler/plugins/customElement.d.ts +1 -1
- package/compiler/plugins/customElement.js +32 -15
- package/compiler/plugins/customElementReact/customElementReact.d.ts +1 -1
- package/compiler/plugins/customElementReact/customElementReact.js +2 -5
- package/compiler/plugins/document.d.ts +2 -4
- package/compiler/plugins/document.js +219 -226
- package/compiler/plugins/extract.d.ts +1 -1
- package/compiler/plugins/extract.js +7 -6
- package/compiler/plugins/finish.d.ts +4 -0
- package/compiler/plugins/finish.js +7 -0
- package/compiler/plugins/index.d.ts +3 -1
- package/compiler/plugins/index.js +3 -1
- package/compiler/plugins/parse.d.ts +1 -1
- package/compiler/plugins/parse.js +1 -4
- package/compiler/plugins/read.d.ts +1 -1
- package/compiler/plugins/read.js +4 -8
- package/compiler/plugins/start.d.ts +4 -0
- package/compiler/plugins/start.js +7 -0
- package/compiler/plugins/style.d.ts +2 -4
- package/compiler/plugins/style.js +19 -21
- package/compiler/plugins/validate.d.ts +1 -1
- package/compiler/plugins/validate.js +1 -4
- package/compiler/plugins/visualStudioCode.d.ts +8 -0
- package/compiler/plugins/visualStudioCode.js +28 -0
- package/compiler/plugins/webTypes.d.ts +2 -2
- package/compiler/plugins/webTypes.js +6 -9
- package/compiler/utils/addDependency.d.ts +4 -0
- package/compiler/utils/addDependency.js +51 -0
- package/compiler/utils/getType.js +1 -1
- package/compiler/utils/index.d.ts +2 -0
- package/compiler/utils/index.js +2 -0
- package/compiler/utils/isDirectoryEmpty.js +1 -1
- package/compiler/utils/removeUnusedImport.d.ts +1 -0
- package/compiler/utils/removeUnusedImport.js +49 -0
- package/compiler/utils/renderTemplate.js +2 -4
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -0
- package/package.json +5 -12
- package/types/context.d.ts +1 -0
- package/types/global.d.ts +1 -1
- package/types/index.d.ts +4 -4
- package/types/index.js +4 -4
- package/types/plugin.d.ts +1 -1
- package/compiler/plugins/external.js +0 -25
- package/compiler/plugins/vscode.d.ts +0 -11
- package/compiler/plugins/vscode.js +0 -83
|
@@ -1,36 +1,34 @@
|
|
|
1
1
|
import t from '@babel/types';
|
|
2
|
-
import fs from 'fs';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import * as CONSTANTS from '../../constants/index.js';
|
|
5
|
+
import { addDependency } from '../utils/index.js';
|
|
5
6
|
const defaults = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
references(context) {
|
|
8
|
+
return [
|
|
9
|
+
path.join(context.directoryPath, `${context.fileName}.css`),
|
|
10
|
+
path.join(context.directoryPath, `${context.fileName}.less`),
|
|
11
|
+
path.join(context.directoryPath, `${context.fileName}.sass`),
|
|
12
|
+
path.join(context.directoryPath, `${context.fileName}.scss`),
|
|
13
|
+
path.join(context.directoryPath, `${context.fileName}.styl`)
|
|
14
|
+
];
|
|
12
15
|
}
|
|
13
16
|
};
|
|
14
17
|
export const style = (options) => {
|
|
15
18
|
const name = 'style';
|
|
16
|
-
options = Object.assign(
|
|
19
|
+
options = Object.assign({}, defaults, options);
|
|
17
20
|
const next = (context) => {
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const stylePath = path.join(directory, `${filename}.${extension}`);
|
|
22
|
-
if (!fs.existsSync(stylePath))
|
|
21
|
+
const references = options.references(context);
|
|
22
|
+
for (const reference of references) {
|
|
23
|
+
if (!fs.existsSync(reference))
|
|
23
24
|
continue;
|
|
24
|
-
context.stylePath =
|
|
25
|
-
break;
|
|
25
|
+
context.stylePath = reference;
|
|
26
26
|
}
|
|
27
27
|
if (!context.stylePath)
|
|
28
28
|
return;
|
|
29
|
-
context.fileAST
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return {
|
|
33
|
-
name,
|
|
34
|
-
next
|
|
29
|
+
const local = addDependency(context.fileAST, context.stylePath, 'AUTO_IMPORT_STYLE');
|
|
30
|
+
const property = t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.identifier(local), undefined, null, undefined, true);
|
|
31
|
+
context.class.body.body.unshift(property);
|
|
35
32
|
};
|
|
33
|
+
return { name, next };
|
|
36
34
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const defaults = {};
|
|
2
|
+
export const visualStudioCode = (options) => {
|
|
3
|
+
const name = 'visualStudioCode';
|
|
4
|
+
options = Object.assign({}, defaults, options);
|
|
5
|
+
const finish = (global) => {
|
|
6
|
+
// TODO
|
|
7
|
+
// {
|
|
8
|
+
// version: 1.1,
|
|
9
|
+
// tags: [
|
|
10
|
+
// {
|
|
11
|
+
// name: context.componentKey,
|
|
12
|
+
// description: {
|
|
13
|
+
// kind: 'markdown',
|
|
14
|
+
// value: description
|
|
15
|
+
// },
|
|
16
|
+
// attributes: properties,
|
|
17
|
+
// references: [
|
|
18
|
+
// {
|
|
19
|
+
// name: 'Source code',
|
|
20
|
+
// url: `https://github.com/htmlplus/core/tree/main/src/components/${context.directoryName}/${context.fileName}.tsx`
|
|
21
|
+
// }
|
|
22
|
+
// ]
|
|
23
|
+
// }
|
|
24
|
+
// ]
|
|
25
|
+
// };
|
|
26
|
+
};
|
|
27
|
+
return { name, finish };
|
|
28
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Global } from '../../types
|
|
1
|
+
import { Global } from '../../types';
|
|
2
2
|
export interface WebTypesOptions {
|
|
3
3
|
destination: string;
|
|
4
|
-
docUrl: () => string;
|
|
5
4
|
packageName: string;
|
|
6
5
|
packageVersion: string;
|
|
6
|
+
docUrl: () => string;
|
|
7
7
|
}
|
|
8
8
|
export declare const webTypes: (options: WebTypesOptions) => {
|
|
9
9
|
name: string;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { camelCase, paramCase } from 'change-case';
|
|
2
|
-
import fs from 'fs';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { getTags, print } from '../utils/index.js';
|
|
5
|
+
const defaults = {};
|
|
5
6
|
export const webTypes = (options) => {
|
|
6
7
|
const name = 'webTypes';
|
|
8
|
+
options = Object.assign({}, defaults, options);
|
|
7
9
|
const finish = (global) => {
|
|
8
10
|
const json = {
|
|
9
11
|
'$schema': 'http://json.schemastore.org/web-types',
|
|
@@ -70,13 +72,8 @@ export const webTypes = (options) => {
|
|
|
70
72
|
}
|
|
71
73
|
};
|
|
72
74
|
const dirname = path.dirname(options.destination);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const raw = JSON.stringify(json, null, 2);
|
|
76
|
-
fs.writeFileSync(options.destination, raw, 'utf8');
|
|
77
|
-
};
|
|
78
|
-
return {
|
|
79
|
-
name,
|
|
80
|
-
finish
|
|
75
|
+
fs.ensureDirSync(dirname);
|
|
76
|
+
fs.writeJSONSync(options.destination, json, { encoding: 'utf8', spaces: 2 });
|
|
81
77
|
};
|
|
78
|
+
return { name, finish };
|
|
82
79
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { File } from '@babel/types';
|
|
2
|
+
export declare function addDependency(path: File | any, source: string): void;
|
|
3
|
+
export declare function addDependency(path: File | any, source: string, local: string): string;
|
|
4
|
+
export declare function addDependency(path: File | any, source: string, local: string, imported: string): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import t from '@babel/types';
|
|
2
|
+
import { visitor } from './visitor.js';
|
|
3
|
+
export function addDependency(path, source, local, imported) {
|
|
4
|
+
const isDefault = local && !imported;
|
|
5
|
+
const isImport = local && imported;
|
|
6
|
+
const isNormal = !local && !imported;
|
|
7
|
+
let declaration;
|
|
8
|
+
let file = path;
|
|
9
|
+
while (file.parentPath)
|
|
10
|
+
file = file.parentPath;
|
|
11
|
+
file = file.node || file;
|
|
12
|
+
visitor(file, {
|
|
13
|
+
ImportDeclaration(path) {
|
|
14
|
+
if (path.node.source.value != source)
|
|
15
|
+
return;
|
|
16
|
+
declaration = path.node;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
if (isNormal && declaration)
|
|
20
|
+
return;
|
|
21
|
+
let specifier = declaration === null || declaration === void 0 ? void 0 : declaration.specifiers.find((specifier) => {
|
|
22
|
+
var _a;
|
|
23
|
+
if (isDefault) {
|
|
24
|
+
return specifier.type == 'ImportDefaultSpecifier';
|
|
25
|
+
}
|
|
26
|
+
else if (isImport) {
|
|
27
|
+
return ((_a = specifier.imported) === null || _a === void 0 ? void 0 : _a.name) == imported;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (specifier)
|
|
31
|
+
return specifier.local.name;
|
|
32
|
+
if (isDefault) {
|
|
33
|
+
specifier = t.importDefaultSpecifier(t.identifier(local));
|
|
34
|
+
}
|
|
35
|
+
else if (isImport) {
|
|
36
|
+
specifier = t.importSpecifier(t.identifier(local), t.identifier(imported));
|
|
37
|
+
}
|
|
38
|
+
if (declaration) {
|
|
39
|
+
if (isDefault) {
|
|
40
|
+
declaration.specifiers.unshift(specifier);
|
|
41
|
+
}
|
|
42
|
+
else if (isImport) {
|
|
43
|
+
declaration.specifiers.push(specifier);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// TODO
|
|
48
|
+
(file.program || file).body.unshift(t.importDeclaration(specifier ? [specifier] : [], t.stringLiteral(source)));
|
|
49
|
+
}
|
|
50
|
+
return local;
|
|
51
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './__dirname.js';
|
|
2
|
+
export * from './addDependency.js';
|
|
2
3
|
export * from './getInitializer.js';
|
|
3
4
|
export * from './getType.js';
|
|
4
5
|
export * from './getTypeReference.js';
|
|
@@ -6,6 +7,7 @@ export * from './hasDecorator.js';
|
|
|
6
7
|
export * from './isDirectoryEmpty.js';
|
|
7
8
|
export * from './printType.js';
|
|
8
9
|
export * from './print.js';
|
|
10
|
+
export * from './removeUnusedImport.js';
|
|
9
11
|
export * from './renderTemplate.js';
|
|
10
12
|
export * from './tags.js';
|
|
11
13
|
export * from './visitor.js';
|
package/compiler/utils/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './__dirname.js';
|
|
2
|
+
export * from './addDependency.js';
|
|
2
3
|
export * from './getInitializer.js';
|
|
3
4
|
export * from './getType.js';
|
|
4
5
|
export * from './getTypeReference.js';
|
|
@@ -6,6 +7,7 @@ export * from './hasDecorator.js';
|
|
|
6
7
|
export * from './isDirectoryEmpty.js';
|
|
7
8
|
export * from './printType.js';
|
|
8
9
|
export * from './print.js';
|
|
10
|
+
export * from './removeUnusedImport.js';
|
|
9
11
|
export * from './renderTemplate.js';
|
|
10
12
|
export * from './tags.js';
|
|
11
13
|
export * from './visitor.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const removeUnusedImport: (ast: any) => void;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import t from '@babel/types';
|
|
2
|
+
import { visitor } from './visitor.js';
|
|
3
|
+
// TODO
|
|
4
|
+
export const removeUnusedImport = (ast) => {
|
|
5
|
+
visitor(ast, {
|
|
6
|
+
Program: {
|
|
7
|
+
exit(path) {
|
|
8
|
+
for (const entry of Object.entries(path.scope.bindings)) {
|
|
9
|
+
let { kind, path, referenced, referencePaths } = entry[1];
|
|
10
|
+
if (kind !== 'module')
|
|
11
|
+
continue;
|
|
12
|
+
if (referenced) {
|
|
13
|
+
referenced = false;
|
|
14
|
+
for (const referencePath of referencePaths) {
|
|
15
|
+
let find = true;
|
|
16
|
+
let parent = referencePath;
|
|
17
|
+
while (parent) {
|
|
18
|
+
if (!parent.node) {
|
|
19
|
+
find = false;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
parent = parent.parentPath;
|
|
23
|
+
}
|
|
24
|
+
if (!find)
|
|
25
|
+
continue;
|
|
26
|
+
referenced = true;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
if (referenced)
|
|
31
|
+
continue;
|
|
32
|
+
const source = path.parentPath.get('source');
|
|
33
|
+
if (!t.isStringLiteral(source))
|
|
34
|
+
continue;
|
|
35
|
+
if (path.isImportSpecifier()) {
|
|
36
|
+
path.remove();
|
|
37
|
+
if (path.parentPath.node.specifiers.length)
|
|
38
|
+
continue;
|
|
39
|
+
path.parentPath.remove();
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (!path.parentPath)
|
|
43
|
+
continue;
|
|
44
|
+
path.parentPath.remove();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import glob from 'fast-glob';
|
|
2
|
-
import fs from 'fs';
|
|
2
|
+
import fs from 'fs-extra';
|
|
3
3
|
import handlebars from 'handlebars';
|
|
4
4
|
import path from 'path';
|
|
5
5
|
export const renderTemplate = (source, destination, options) => (context) => {
|
|
@@ -17,9 +17,7 @@ export const renderTemplate = (source, destination, options) => (context) => {
|
|
|
17
17
|
const directory = path.dirname(to);
|
|
18
18
|
const raw = fs.readFileSync(from, 'utf8');
|
|
19
19
|
const template = handlebars.compile(raw)(context);
|
|
20
|
-
|
|
21
|
-
fs.mkdirSync(directory, { recursive: true });
|
|
22
|
-
}
|
|
20
|
+
fs.ensureDirSync(directory);
|
|
23
21
|
fs.writeFileSync(to, template, 'utf8');
|
|
24
22
|
}
|
|
25
23
|
};
|
package/constants/index.d.ts
CHANGED
package/constants/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlplus/element",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.7",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Masood Abdolian <m.abdolian@gmail.com>",
|
|
6
6
|
"description": "Compiler of HTMLPlus",
|
|
@@ -8,13 +8,7 @@
|
|
|
8
8
|
"main": "client/index.js",
|
|
9
9
|
"types": "client/index.d.ts",
|
|
10
10
|
"files": [
|
|
11
|
-
"
|
|
12
|
-
"compiler",
|
|
13
|
-
"constants",
|
|
14
|
-
"runtime",
|
|
15
|
-
"types",
|
|
16
|
-
"package.json",
|
|
17
|
-
"README.md"
|
|
11
|
+
"**/*.*"
|
|
18
12
|
],
|
|
19
13
|
"publishConfig": {
|
|
20
14
|
"directory": "dist"
|
|
@@ -25,12 +19,12 @@
|
|
|
25
19
|
"keywords": [],
|
|
26
20
|
"repository": {
|
|
27
21
|
"type": "git",
|
|
28
|
-
"url": "git+https://github.com/htmlplus/
|
|
22
|
+
"url": "git+https://github.com/htmlplus/htmlplus.git"
|
|
29
23
|
},
|
|
30
24
|
"bugs": {
|
|
31
|
-
"url": "https://github.com/htmlplus/
|
|
25
|
+
"url": "https://github.com/htmlplus/htmlplus/issues"
|
|
32
26
|
},
|
|
33
|
-
"homepage": "https://github.com/htmlplus/
|
|
27
|
+
"homepage": "https://github.com/htmlplus/htmlplus#readme",
|
|
34
28
|
"dependencies": {
|
|
35
29
|
"@babel/generator": "^7.18.9",
|
|
36
30
|
"@babel/parser": "^7.18.9",
|
|
@@ -41,7 +35,6 @@
|
|
|
41
35
|
"fast-glob": "^3.2.11",
|
|
42
36
|
"fs-extra": "^10.1.0",
|
|
43
37
|
"handlebars": "^4.7.7",
|
|
44
|
-
"listr2": "^5.0.1",
|
|
45
38
|
"ora": "^6.1.2",
|
|
46
39
|
"typescript": "^4.7.4"
|
|
47
40
|
},
|
package/types/context.d.ts
CHANGED
package/types/global.d.ts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './context
|
|
2
|
-
export * from './global
|
|
3
|
-
export * from './plugin
|
|
4
|
-
export * from './plusElement
|
|
1
|
+
export * from './context';
|
|
2
|
+
export * from './global';
|
|
3
|
+
export * from './plugin';
|
|
4
|
+
export * from './plusElement';
|
package/types/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './context
|
|
2
|
-
export * from './global
|
|
3
|
-
export * from './plugin
|
|
4
|
-
export * from './plusElement
|
|
1
|
+
export * from './context';
|
|
2
|
+
export * from './global';
|
|
3
|
+
export * from './plugin';
|
|
4
|
+
export * from './plusElement';
|
package/types/plugin.d.ts
CHANGED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
const defaults = {
|
|
4
|
-
source(context) {
|
|
5
|
-
return path.join(context.directoryPath, 'external');
|
|
6
|
-
},
|
|
7
|
-
destination(context) {
|
|
8
|
-
return '';
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
export const external = (options) => {
|
|
12
|
-
const name = 'external';
|
|
13
|
-
options = Object.assign(Object.assign({}, defaults), options);
|
|
14
|
-
const next = (context) => {
|
|
15
|
-
var _a;
|
|
16
|
-
const source = (_a = options.source) === null || _a === void 0 ? void 0 : _a.call(options, context);
|
|
17
|
-
if (!source || !fs.existsSync(source))
|
|
18
|
-
return;
|
|
19
|
-
fs.copySync(source, options.destination(context));
|
|
20
|
-
};
|
|
21
|
-
return {
|
|
22
|
-
name,
|
|
23
|
-
next
|
|
24
|
-
};
|
|
25
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Context } from '../../types/index.js';
|
|
2
|
-
export interface VscodeOptions {
|
|
3
|
-
dist: string;
|
|
4
|
-
prefix: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const vscode: (options: VscodeOptions) => {
|
|
7
|
-
name: string;
|
|
8
|
-
start: (global: any) => void;
|
|
9
|
-
next: (context: Context, global: any) => void;
|
|
10
|
-
finish: (global: any) => void;
|
|
11
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { paramCase } from 'change-case';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { getTags, getType, printType } from '../utils/index.js';
|
|
5
|
-
export const vscode = (options) => {
|
|
6
|
-
const name = 'vscode';
|
|
7
|
-
const start = (global) => {
|
|
8
|
-
global.vscode = {
|
|
9
|
-
version: 1.1,
|
|
10
|
-
tags: []
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const next = (context, global) => {
|
|
14
|
-
const readme = (() => {
|
|
15
|
-
try {
|
|
16
|
-
const source = path.resolve(context.directoryPath || '', `${context.fileName}.md`);
|
|
17
|
-
return fs.readFileSync(source, 'utf8');
|
|
18
|
-
}
|
|
19
|
-
catch (_a) { }
|
|
20
|
-
})();
|
|
21
|
-
const description = (() => {
|
|
22
|
-
const content = readme || '';
|
|
23
|
-
if (!content.startsWith('# '))
|
|
24
|
-
return '';
|
|
25
|
-
const sections = content.split('\n');
|
|
26
|
-
for (let i = 1; i < sections.length; i++) {
|
|
27
|
-
const section = sections[i].trim();
|
|
28
|
-
if (!section)
|
|
29
|
-
continue;
|
|
30
|
-
return section;
|
|
31
|
-
}
|
|
32
|
-
return '';
|
|
33
|
-
})();
|
|
34
|
-
const properties = (context.classProperties || []).map((property) => {
|
|
35
|
-
var _a;
|
|
36
|
-
const name = paramCase(property.key['name']);
|
|
37
|
-
const description = (_a = getTags(property).find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
38
|
-
const attribute = {
|
|
39
|
-
name,
|
|
40
|
-
description
|
|
41
|
-
};
|
|
42
|
-
// TODO
|
|
43
|
-
let { members = [] } = (() => {
|
|
44
|
-
const ast = getType(context.fileAST, (property.typeAnnotation || {})['typeAnnotation'], {
|
|
45
|
-
directory: context.directoryPath
|
|
46
|
-
});
|
|
47
|
-
return printType(ast);
|
|
48
|
-
})();
|
|
49
|
-
// TODO
|
|
50
|
-
members = members.filter((member) => member.key !== member.type).map((member) => ({ name: member.key }));
|
|
51
|
-
if (members.length)
|
|
52
|
-
attribute.values = members;
|
|
53
|
-
return attribute;
|
|
54
|
-
});
|
|
55
|
-
global.vscode.tags.push({
|
|
56
|
-
name: context.componentKey,
|
|
57
|
-
description: {
|
|
58
|
-
kind: 'markdown',
|
|
59
|
-
value: description
|
|
60
|
-
},
|
|
61
|
-
attributes: properties,
|
|
62
|
-
references: [
|
|
63
|
-
{
|
|
64
|
-
name: 'Source code',
|
|
65
|
-
url: `https://github.com/htmlplus/core/tree/main/src/components/${context.directoryName}/${context.fileName}.tsx`
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
const finish = (global) => {
|
|
71
|
-
global.vscode.tags = global.vscode.tags.sort((a, b) => (a.name > b.name ? 1 : -1));
|
|
72
|
-
// TODO
|
|
73
|
-
// fs.ensureDirSync(path.dirname(options.dist));
|
|
74
|
-
// TODO
|
|
75
|
-
// fs.writeJSONSync(options.dist, global.vscode, { replacer: null, spaces: 2 });
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
name,
|
|
79
|
-
start,
|
|
80
|
-
next,
|
|
81
|
-
finish
|
|
82
|
-
};
|
|
83
|
-
};
|