@htmlplus/element 2.11.0 → 2.13.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.
Files changed (175) hide show
  1. package/README.md +2 -2
  2. package/bundlers.d.ts +20 -0
  3. package/{bundlers/vite.js → bundlers.js} +39 -3
  4. package/client-5FqNUiuz.d.ts +309 -0
  5. package/client-Dse96R-O.js +1805 -0
  6. package/client.d.ts +1 -0
  7. package/client.js +3 -0
  8. package/constants.d.ts +48 -0
  9. package/constants.js +60 -0
  10. package/internal.d.ts +1 -0
  11. package/internal.js +3 -0
  12. package/package.json +8 -4
  13. package/transformer.d.ts +139 -0
  14. package/transformer.js +1277 -0
  15. package/bundlers/rollup.d.ts +0 -7
  16. package/bundlers/rollup.js +0 -23
  17. package/bundlers/vite.d.ts +0 -8
  18. package/client/decorators/bind.d.ts +0 -8
  19. package/client/decorators/bind.js +0 -21
  20. package/client/decorators/context.d.ts +0 -3
  21. package/client/decorators/context.js +0 -121
  22. package/client/decorators/direction.d.ts +0 -5
  23. package/client/decorators/direction.js +0 -8
  24. package/client/decorators/element.d.ts +0 -7
  25. package/client/decorators/element.js +0 -65
  26. package/client/decorators/event.d.ts +0 -35
  27. package/client/decorators/event.js +0 -53
  28. package/client/decorators/host.d.ts +0 -4
  29. package/client/decorators/host.js +0 -7
  30. package/client/decorators/index.d.ts +0 -15
  31. package/client/decorators/index.js +0 -15
  32. package/client/decorators/isRTL.d.ts +0 -4
  33. package/client/decorators/isRTL.js +0 -7
  34. package/client/decorators/listen.d.ts +0 -52
  35. package/client/decorators/listen.js +0 -37
  36. package/client/decorators/method.d.ts +0 -6
  37. package/client/decorators/method.js +0 -15
  38. package/client/decorators/property.d.ts +0 -25
  39. package/client/decorators/property.js +0 -94
  40. package/client/decorators/query.d.ts +0 -9
  41. package/client/decorators/query.js +0 -12
  42. package/client/decorators/queryAll.d.ts +0 -12
  43. package/client/decorators/queryAll.js +0 -15
  44. package/client/decorators/slots.d.ts +0 -4
  45. package/client/decorators/slots.js +0 -7
  46. package/client/decorators/state.d.ts +0 -6
  47. package/client/decorators/state.js +0 -23
  48. package/client/decorators/watch.d.ts +0 -11
  49. package/client/decorators/watch.js +0 -31
  50. package/client/index.d.ts +0 -2
  51. package/client/index.js +0 -2
  52. package/client/utils/appendToMethod.d.ts +0 -1
  53. package/client/utils/appendToMethod.js +0 -15
  54. package/client/utils/attributes.d.ts +0 -2
  55. package/client/utils/attributes.js +0 -33
  56. package/client/utils/call.d.ts +0 -1
  57. package/client/utils/call.js +0 -3
  58. package/client/utils/classes.d.ts +0 -4
  59. package/client/utils/classes.js +0 -45
  60. package/client/utils/config.d.ts +0 -39
  61. package/client/utils/config.js +0 -28
  62. package/client/utils/defineProperty.d.ts +0 -1
  63. package/client/utils/defineProperty.js +0 -1
  64. package/client/utils/direction.d.ts +0 -6
  65. package/client/utils/direction.js +0 -8
  66. package/client/utils/event.d.ts +0 -13
  67. package/client/utils/event.js +0 -48
  68. package/client/utils/getFramework.d.ts +0 -2
  69. package/client/utils/getFramework.js +0 -20
  70. package/client/utils/getStyles.d.ts +0 -2
  71. package/client/utils/getStyles.js +0 -4
  72. package/client/utils/getTag.d.ts +0 -2
  73. package/client/utils/getTag.js +0 -4
  74. package/client/utils/host.d.ts +0 -5
  75. package/client/utils/host.js +0 -12
  76. package/client/utils/index.d.ts +0 -32
  77. package/client/utils/index.js +0 -32
  78. package/client/utils/isCSSColor.d.ts +0 -5
  79. package/client/utils/isCSSColor.js +0 -9
  80. package/client/utils/isEvent.d.ts +0 -1
  81. package/client/utils/isEvent.js +0 -3
  82. package/client/utils/isRTL.d.ts +0 -5
  83. package/client/utils/isRTL.js +0 -5
  84. package/client/utils/isServer.d.ts +0 -4
  85. package/client/utils/isServer.js +0 -6
  86. package/client/utils/merge.d.ts +0 -1
  87. package/client/utils/merge.js +0 -22
  88. package/client/utils/query.d.ts +0 -5
  89. package/client/utils/query.js +0 -7
  90. package/client/utils/queryAll.d.ts +0 -5
  91. package/client/utils/queryAll.js +0 -7
  92. package/client/utils/request.d.ts +0 -9
  93. package/client/utils/request.js +0 -65
  94. package/client/utils/shadowRoot.d.ts +0 -2
  95. package/client/utils/shadowRoot.js +0 -4
  96. package/client/utils/slots.d.ts +0 -9
  97. package/client/utils/slots.js +0 -18
  98. package/client/utils/styles.d.ts +0 -4
  99. package/client/utils/styles.js +0 -10
  100. package/client/utils/task.d.ts +0 -6
  101. package/client/utils/task.js +0 -34
  102. package/client/utils/toBoolean.d.ts +0 -1
  103. package/client/utils/toBoolean.js +0 -3
  104. package/client/utils/toDecorator.d.ts +0 -2
  105. package/client/utils/toDecorator.js +0 -10
  106. package/client/utils/toEvent.d.ts +0 -1
  107. package/client/utils/toEvent.js +0 -3
  108. package/client/utils/toProperty.d.ts +0 -1
  109. package/client/utils/toProperty.js +0 -55
  110. package/client/utils/toUnit.d.ts +0 -4
  111. package/client/utils/toUnit.js +0 -10
  112. package/client/utils/typeOf.d.ts +0 -3
  113. package/client/utils/typeOf.js +0 -6
  114. package/client/utils/uhtml.d.ts +0 -22
  115. package/client/utils/uhtml.js +0 -703
  116. package/client/utils/updateAttribute.d.ts +0 -2
  117. package/client/utils/updateAttribute.js +0 -10
  118. package/constants/index.d.ts +0 -47
  119. package/constants/index.js +0 -59
  120. package/transformer/index.d.ts +0 -3
  121. package/transformer/index.js +0 -3
  122. package/transformer/plugins/assets.d.ts +0 -7
  123. package/transformer/plugins/assets.js +0 -26
  124. package/transformer/plugins/copy.d.ts +0 -9
  125. package/transformer/plugins/copy.js +0 -29
  126. package/transformer/plugins/customElement.d.ts +0 -7
  127. package/transformer/plugins/customElement.js +0 -383
  128. package/transformer/plugins/document.d.ts +0 -7
  129. package/transformer/plugins/document.js +0 -206
  130. package/transformer/plugins/extract.d.ts +0 -2
  131. package/transformer/plugins/extract.js +0 -22
  132. package/transformer/plugins/index.d.ts +0 -12
  133. package/transformer/plugins/index.js +0 -12
  134. package/transformer/plugins/parse.d.ts +0 -6
  135. package/transformer/plugins/parse.js +0 -13
  136. package/transformer/plugins/read.d.ts +0 -7
  137. package/transformer/plugins/read.js +0 -19
  138. package/transformer/plugins/readme.d.ts +0 -6
  139. package/transformer/plugins/readme.js +0 -24
  140. package/transformer/plugins/style.d.ts +0 -6
  141. package/transformer/plugins/style.js +0 -42
  142. package/transformer/plugins/validate.d.ts +0 -2
  143. package/transformer/plugins/validate.js +0 -40
  144. package/transformer/plugins/visualStudioCode.d.ts +0 -8
  145. package/transformer/plugins/visualStudioCode.js +0 -73
  146. package/transformer/plugins/webTypes.d.ts +0 -10
  147. package/transformer/plugins/webTypes.js +0 -74
  148. package/transformer/transformer.d.ts +0 -8
  149. package/transformer/transformer.js +0 -78
  150. package/transformer/transformer.types.d.ts +0 -52
  151. package/transformer/transformer.types.js +0 -1
  152. package/transformer/utils/addDependency.d.ts +0 -7
  153. package/transformer/utils/addDependency.js +0 -64
  154. package/transformer/utils/extractAttribute.d.ts +0 -2
  155. package/transformer/utils/extractAttribute.js +0 -10
  156. package/transformer/utils/extractFromComment.d.ts +0 -4
  157. package/transformer/utils/extractFromComment.js +0 -51
  158. package/transformer/utils/getInitializer.d.ts +0 -2
  159. package/transformer/utils/getInitializer.js +0 -3
  160. package/transformer/utils/getType.d.ts +0 -2
  161. package/transformer/utils/getType.js +0 -89
  162. package/transformer/utils/getTypeReference.d.ts +0 -2
  163. package/transformer/utils/getTypeReference.js +0 -33
  164. package/transformer/utils/hasDecorator.d.ts +0 -1
  165. package/transformer/utils/hasDecorator.js +0 -5
  166. package/transformer/utils/index.d.ts +0 -10
  167. package/transformer/utils/index.js +0 -10
  168. package/transformer/utils/print.d.ts +0 -2
  169. package/transformer/utils/print.js +0 -5
  170. package/transformer/utils/printType.d.ts +0 -1
  171. package/transformer/utils/printType.js +0 -69
  172. package/transformer/utils/visitor.d.ts +0 -2
  173. package/transformer/utils/visitor.js +0 -5
  174. package/types/index.d.ts +0 -2
  175. package/types/index.js +0 -1
@@ -1,78 +0,0 @@
1
- import ora from 'ora';
2
- import path from 'path';
3
- const logger = ora({
4
- color: 'yellow'
5
- });
6
- const log = (message, persist) => {
7
- const content = `${new Date().toLocaleTimeString()} [HTMLPLUS] ${message}`;
8
- const log = logger.start(content);
9
- if (!persist)
10
- return;
11
- log.succeed();
12
- };
13
- export const transformer = (...plugins) => {
14
- let global = {
15
- contexts: []
16
- };
17
- const start = async () => {
18
- log(`Started.`, true);
19
- log(`${plugins.length} plugins found.`, true);
20
- log(`Plugins are starting.`, true);
21
- for (const plugin of plugins) {
22
- if (!plugin.start)
23
- continue;
24
- log(`Plugin '${plugin.name}' is starting.`);
25
- global = (await plugin.start(global)) || global;
26
- log(`Plugin '${plugin.name}' started successfully.`);
27
- }
28
- log(`Plugins started successfully.`, true);
29
- };
30
- const run = async (filePath) => {
31
- const key = path.join(filePath).split(path.sep).pop();
32
- let context = {
33
- filePath
34
- };
35
- const parsed = path.parse(filePath);
36
- for (const plugin of plugins) {
37
- if (!plugin.run)
38
- continue;
39
- const source = path.join(parsed.dir).split(path.sep).slice(-2).concat(parsed.base).join('/');
40
- log(`Plugin '${plugin.name}' is executing on '${source}' file.`);
41
- try {
42
- context = (await plugin.run(context, global)) || context;
43
- }
44
- catch (error) {
45
- log(`Error in '${plugin.name}' plugin on '${source}' file.\n`, true);
46
- throw error;
47
- }
48
- global.contexts = global.contexts
49
- .filter((current) => {
50
- return current.filePath != context.filePath;
51
- })
52
- .concat(context);
53
- log(`Plugin '${plugin.name}' executed successfully on '${source}' file.`);
54
- }
55
- logger.stop();
56
- return context;
57
- };
58
- const finish = async () => {
59
- log(`Plugins are finishing.`, true);
60
- for (const plugin of plugins) {
61
- if (!plugin.finish)
62
- continue;
63
- log(`Plugin '${plugin.name}' is finishing.`);
64
- global = (await plugin.finish(global)) || global;
65
- log(`Plugin '${plugin.name}' finished successfully.`);
66
- }
67
- log(`Plugins finished successfully.`, true);
68
- log(`Finished.`, true);
69
- };
70
- const write = async () => {
71
- for (const plugin of plugins) {
72
- if (!plugin.write)
73
- continue;
74
- global = (await plugin.write(global)) || global;
75
- }
76
- };
77
- return { global, start, run, finish, write };
78
- };
@@ -1,52 +0,0 @@
1
- import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
2
- type Return<T> = void | T | Promise<void | T>;
3
- export interface TransformerPluginContext {
4
- skipped?: boolean;
5
- script?: string;
6
- assetsDestination?: string;
7
- assetsSource?: string;
8
- class?: ClassDeclaration;
9
- classEvents?: Array<ClassProperty>;
10
- classMembers?: ClassBody['body'];
11
- classMethods?: Array<ClassMethod>;
12
- className?: string;
13
- classProperties?: Array<ClassProperty>;
14
- classStates?: Array<ClassProperty>;
15
- directoryName?: string;
16
- directoryPath?: string;
17
- elementKey?: string;
18
- elementInterfaceName?: string;
19
- elementTagName?: string;
20
- fileAST?: File;
21
- fileContent?: string;
22
- fileExtension?: string;
23
- fileName?: string;
24
- filePath?: string;
25
- metadata?: {
26
- [key: string]: any;
27
- };
28
- readmeContent?: string;
29
- readmeExtension?: string;
30
- readmeName?: string;
31
- readmePath?: string;
32
- styleContent?: string;
33
- styleContentTransformed?: string;
34
- styleExtension?: string;
35
- styleName?: string;
36
- stylePath?: string;
37
- }
38
- export interface TransformerPluginGlobal {
39
- contexts: Array<TransformerPluginContext>;
40
- metadata?: {
41
- [key: string]: any;
42
- };
43
- }
44
- export interface TransformerPlugin {
45
- name: string;
46
- options?: any;
47
- start?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
48
- run?: (context: TransformerPluginContext, global: TransformerPluginGlobal) => Return<TransformerPluginContext>;
49
- finish?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
50
- write?: (global: TransformerPluginGlobal) => Return<TransformerPluginGlobal>;
51
- }
52
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,7 +0,0 @@
1
- import t from '@babel/types';
2
- interface AddDependencyReturns {
3
- local?: string;
4
- node: t.ImportDeclaration;
5
- }
6
- export declare function addDependency(path: t.File | any, source: string, local?: string, imported?: string, comment?: boolean): AddDependencyReturns;
7
- export {};
@@ -1,64 +0,0 @@
1
- import t from '@babel/types';
2
- import * as CONSTANTS from '../../constants/index.js';
3
- import { visitor } from './visitor.js';
4
- export function addDependency(path, source, local, imported, comment) {
5
- const isDefault = local && !imported;
6
- const isImport = local && imported;
7
- const isNormal = !local && !imported;
8
- let declaration;
9
- let file = path;
10
- while (file.parentPath)
11
- file = file.parentPath;
12
- file = file.node || file;
13
- visitor(file, {
14
- ImportDeclaration(path) {
15
- if (path.node.source.value != source)
16
- return;
17
- declaration = path.node;
18
- }
19
- });
20
- if (isNormal && declaration)
21
- return {
22
- node: declaration
23
- };
24
- let specifier = declaration?.specifiers.find((specifier) => {
25
- if (isDefault) {
26
- return specifier.type == 'ImportDefaultSpecifier';
27
- }
28
- else if (isImport) {
29
- return specifier.imported?.name == imported;
30
- }
31
- });
32
- if (specifier)
33
- return {
34
- local: specifier.local.name,
35
- node: declaration
36
- };
37
- if (isDefault) {
38
- specifier = t.importDefaultSpecifier(t.identifier(local));
39
- }
40
- else if (isImport) {
41
- specifier = t.importSpecifier(t.identifier(local), t.identifier(imported));
42
- }
43
- if (declaration) {
44
- if (isDefault) {
45
- declaration.specifiers.unshift(specifier);
46
- }
47
- else if (isImport) {
48
- declaration.specifiers.push(specifier);
49
- }
50
- }
51
- else {
52
- declaration = t.importDeclaration(specifier ? [specifier] : [], t.stringLiteral(source));
53
- // TODO
54
- (file.program || file).body.unshift(declaration);
55
- // TODO
56
- if (comment) {
57
- t.addComment(declaration, 'leading', CONSTANTS.COMMENT_AUTO_ADDED, true);
58
- }
59
- }
60
- return {
61
- local,
62
- node: declaration
63
- };
64
- }
@@ -1,2 +0,0 @@
1
- import t from '@babel/types';
2
- export declare const extractAttribute: (property: t.ClassProperty) => string | undefined;
@@ -1,10 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- export const extractAttribute = (property) => {
3
- try {
4
- return property.decorators
5
- .find((decorator) => decorator.expression.callee.name == CONSTANTS.DECORATOR_PROPERTY)
6
- .expression.arguments[0].properties.find((property) => property.key.name == 'attribute').value
7
- .value;
8
- }
9
- catch { }
10
- };
@@ -1,4 +0,0 @@
1
- import t from '@babel/types';
2
- export declare const extractFromComment: (node: t.Node, whitelist?: string[]) => {
3
- [key: string]: any;
4
- };
@@ -1,51 +0,0 @@
1
- export const extractFromComment = (node, whitelist) => {
2
- const normalized = [];
3
- const result = {
4
- description: ''
5
- };
6
- const lines = node.leadingComments
7
- ?.map((comment) => {
8
- if (comment.type == 'CommentLine')
9
- return comment.value;
10
- return comment.value.split('\n');
11
- })
12
- ?.flat()
13
- ?.map((line) => line.trim().replace(/^\*/, '').trim())
14
- ?.filter((line) => line.trim());
15
- for (const line of lines || []) {
16
- if (line.startsWith('@')) {
17
- normalized.push(line);
18
- continue;
19
- }
20
- if (!normalized.length)
21
- normalized.push('');
22
- normalized[normalized.length - 1] += ' ' + line;
23
- }
24
- for (const line of normalized) {
25
- if (!line.startsWith('@')) {
26
- result.description = line.trim();
27
- continue;
28
- }
29
- const regex = /@(\w+)(?:\s*({\w+})\s*)?(?:\s*([-a-zA-Z\s]+)\s*-\s*)?(.*)/;
30
- const groups = regex.exec(line);
31
- if (!groups)
32
- continue;
33
- const tag = groups[1]?.trim();
34
- const type = groups[2]?.trim().slice(1, -1);
35
- const name = groups[3]?.trim();
36
- const description = groups[4]?.trim();
37
- if (name && description) {
38
- const key = tag + 's';
39
- if (whitelist && !whitelist.includes(key))
40
- continue;
41
- (result[key] ||= []).push({ name, type, description });
42
- }
43
- else {
44
- const key = tag;
45
- if (whitelist && !whitelist.includes(key))
46
- continue;
47
- result[key] = description || true;
48
- }
49
- }
50
- return result;
51
- };
@@ -1,2 +0,0 @@
1
- import t from '@babel/types';
2
- export declare const getInitializer: (node: t.Expression) => string | undefined;
@@ -1,3 +0,0 @@
1
- export const getInitializer = (node) => {
2
- return node?.extra?.raw || node?.['value'];
3
- };
@@ -1,2 +0,0 @@
1
- import t from '@babel/types';
2
- export declare const getType: (directory: string, file: t.File, node: t.Node) => t.Node;
@@ -1,89 +0,0 @@
1
- import { parse } from '@babel/parser';
2
- import fs from 'fs-extra';
3
- import { glob } from 'glob';
4
- import { dirname, resolve } from 'path';
5
- import { join } from 'path';
6
- import { visitor } from './visitor.js';
7
- export const getType = (directory, file, node) => {
8
- if (!node)
9
- return node;
10
- if (node.type != 'TSTypeReference')
11
- return node;
12
- let result;
13
- visitor(file, {
14
- ClassDeclaration(path) {
15
- if (path.node.id.name != node.typeName['name'])
16
- return;
17
- result = path.node;
18
- path.stop();
19
- },
20
- ImportDeclaration(path) {
21
- for (const specifier of path.node.specifiers) {
22
- const alias = specifier.local.name;
23
- if (alias != node.typeName['name'])
24
- continue;
25
- let key;
26
- switch (specifier.type) {
27
- case 'ImportNamespaceSpecifier':
28
- key = '*';
29
- break;
30
- case 'ImportDefaultSpecifier':
31
- key = 'default';
32
- break;
33
- case 'ImportSpecifier':
34
- key = specifier.imported.name;
35
- break;
36
- }
37
- try {
38
- const reference = glob
39
- .sync(['.ts*', '/index.ts*'].map((key) => {
40
- return join(directory, path.node.source.value).replace(/\\/g, '/') + key;
41
- }))
42
- .find((reference) => fs.existsSync(reference));
43
- const content = fs.readFileSync(reference, 'utf8');
44
- const filePath = resolve(directory, path.node.source.value + '.ts');
45
- path.$ast ||= parse(content, {
46
- allowImportExportEverywhere: true,
47
- plugins: ['typescript'],
48
- ranges: false
49
- });
50
- result = getType(dirname(filePath), path.$ast, node);
51
- }
52
- catch { }
53
- path.stop();
54
- break;
55
- }
56
- },
57
- TSInterfaceDeclaration(path) {
58
- if (path.node.id.name != node.typeName['name'])
59
- return;
60
- result = path.node;
61
- path.stop();
62
- },
63
- TSTypeAliasDeclaration(path) {
64
- if (path.node.id.name != node.typeName['name'])
65
- return;
66
- result = path.node.typeAnnotation;
67
- switch (result.type) {
68
- case 'TSUnionType':
69
- const types = [];
70
- for (const prev of result.types) {
71
- const next = getType(directory, file, prev);
72
- if (next.type == 'TSUnionType') {
73
- next.types.forEach((type) => types.push(type));
74
- }
75
- else {
76
- types.push(next);
77
- }
78
- }
79
- result.types = types;
80
- break;
81
- default:
82
- result = getType(directory, file, result);
83
- break;
84
- }
85
- path.stop();
86
- }
87
- });
88
- return result || node;
89
- };
@@ -1,2 +0,0 @@
1
- import { File, Node } from '@babel/types';
2
- export declare const getTypeReference: (file: File, node: Node) => string | undefined;
@@ -1,33 +0,0 @@
1
- import { visitor } from './visitor.js';
2
- export const getTypeReference = (file, node) => {
3
- if (!node)
4
- return;
5
- if (node.type != 'TSTypeReference')
6
- return;
7
- let result;
8
- visitor(file, {
9
- ImportDeclaration(path) {
10
- for (const specifier of path.node.specifiers) {
11
- const alias = specifier.local.name;
12
- if (alias != node.typeName['name'])
13
- continue;
14
- let key;
15
- switch (specifier.type) {
16
- case 'ImportNamespaceSpecifier':
17
- key = '*';
18
- break;
19
- case 'ImportDefaultSpecifier':
20
- key = 'default';
21
- break;
22
- case 'ImportSpecifier':
23
- key = specifier.imported.name;
24
- break;
25
- }
26
- result = path.node.source.value;
27
- path.stop();
28
- break;
29
- }
30
- }
31
- });
32
- return result;
33
- };
@@ -1 +0,0 @@
1
- export declare const hasDecorator: (node: any, name: string) => boolean;
@@ -1,5 +0,0 @@
1
- export const hasDecorator = (node, name) => {
2
- if (!node.decorators)
3
- return false;
4
- return !!node.decorators.some((decorator) => decorator.expression.callee?.name == name);
5
- };
@@ -1,10 +0,0 @@
1
- export * from './addDependency.js';
2
- export * from './extractAttribute.js';
3
- export * from './extractFromComment.js';
4
- export * from './getInitializer.js';
5
- export * from './getType.js';
6
- export * from './getTypeReference.js';
7
- export * from './hasDecorator.js';
8
- export * from './printType.js';
9
- export * from './print.js';
10
- export * from './visitor.js';
@@ -1,10 +0,0 @@
1
- export * from './addDependency.js';
2
- export * from './extractAttribute.js';
3
- export * from './extractFromComment.js';
4
- export * from './getInitializer.js';
5
- export * from './getType.js';
6
- export * from './getTypeReference.js';
7
- export * from './hasDecorator.js';
8
- export * from './printType.js';
9
- export * from './print.js';
10
- export * from './visitor.js';
@@ -1,2 +0,0 @@
1
- import { Node } from '@babel/types';
2
- export declare const print: (ast: Node) => string;
@@ -1,5 +0,0 @@
1
- import generator from '@babel/generator';
2
- // TODO: add options
3
- export const print = (ast) => {
4
- return (generator.default || generator)(ast, { decoratorsBeforeExport: true }).code;
5
- };
@@ -1 +0,0 @@
1
- export declare const printType: (ast: any) => any;
@@ -1,69 +0,0 @@
1
- import { print } from './print.js';
2
- // TODO
3
- // args types
4
- // return type
5
- // elements\grid-item\grid-item.types.ts
6
- // elements\portal\portal.tsx
7
- export const printType = (ast) => {
8
- if (!ast)
9
- return ast;
10
- let result = {};
11
- switch (ast.type) {
12
- case 'BooleanLiteral':
13
- case 'NumericLiteral':
14
- case 'StringLiteral': {
15
- result.key = ast.value;
16
- result.type = ast.type.replace('Literal', '').toLowerCase();
17
- break;
18
- }
19
- case 'TSBooleanKeyword':
20
- case 'TSNumberKeyword':
21
- case 'TSStringKeyword': {
22
- const type = ast.type.replace('TS', '').replace('Keyword', '').toLowerCase();
23
- result.key = type;
24
- result.type = type;
25
- break;
26
- }
27
- case 'TSAnyKeyword': {
28
- result.type = 'any';
29
- break;
30
- }
31
- case 'TSArrayType': {
32
- const type = print(ast.elementType) + '[]';
33
- result.key = type;
34
- result.type = type;
35
- break;
36
- }
37
- case 'TSInterfaceDeclaration': {
38
- result.type = ast.id.name;
39
- result.members = ast.body.body.map((body) => printType(body));
40
- break;
41
- }
42
- case 'TSLiteralType': {
43
- result = printType(ast.literal);
44
- break;
45
- }
46
- case 'TSPropertySignature': {
47
- const { typeAnnotation } = ast;
48
- result.key = ast.key.name;
49
- if (typeAnnotation && typeAnnotation.typeAnnotation)
50
- result.type = printType(ast.typeAnnotation.typeAnnotation).type;
51
- break;
52
- }
53
- case 'TSTypeAliasDeclaration': {
54
- result = printType(ast.typeAnnotation);
55
- break;
56
- }
57
- case 'TSTypeReference': {
58
- result.key = ast.typeName.name;
59
- result.type = ast.typeName.name;
60
- break;
61
- }
62
- case 'TSUnionType': {
63
- result.type = print(ast);
64
- result.members = ast.types.map((type) => printType(type));
65
- break;
66
- }
67
- }
68
- return result;
69
- };
@@ -1,2 +0,0 @@
1
- import { Node } from '@babel/types';
2
- export declare const visitor: (ast: Node, options: any) => void;
@@ -1,5 +0,0 @@
1
- import traverse from '@babel/traverse';
2
- // TODO: options type
3
- export const visitor = (ast, options) => {
4
- (traverse.default || traverse)(ast, options);
5
- };
package/types/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export interface HTMLPlusElement {
2
- }
package/types/index.js DELETED
@@ -1 +0,0 @@
1
- export {};