@htmlplus/element 0.1.9 → 0.3.1

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 (162) hide show
  1. package/README.md +34 -4
  2. package/package.json +10 -47
  3. package/dist/client/decorators/attributes.d.ts +0 -2
  4. package/dist/client/decorators/attributes.js +0 -13
  5. package/dist/client/decorators/bind.d.ts +0 -4
  6. package/dist/client/decorators/bind.js +0 -17
  7. package/dist/client/decorators/element.d.ts +0 -2
  8. package/dist/client/decorators/element.js +0 -49
  9. package/dist/client/decorators/event.d.ts +0 -21
  10. package/dist/client/decorators/event.js +0 -18
  11. package/dist/client/decorators/index.d.ts +0 -9
  12. package/dist/client/decorators/index.js +0 -9
  13. package/dist/client/decorators/listen.d.ts +0 -12
  14. package/dist/client/decorators/listen.js +0 -30
  15. package/dist/client/decorators/method.d.ts +0 -2
  16. package/dist/client/decorators/method.js +0 -12
  17. package/dist/client/decorators/property.d.ts +0 -12
  18. package/dist/client/decorators/property.js +0 -51
  19. package/dist/client/decorators/state.d.ts +0 -2
  20. package/dist/client/decorators/state.js +0 -32
  21. package/dist/client/decorators/watch.d.ts +0 -2
  22. package/dist/client/decorators/watch.js +0 -17
  23. package/dist/client/helpers/classes.d.ts +0 -1
  24. package/dist/client/helpers/classes.js +0 -62
  25. package/dist/client/helpers/direction.d.ts +0 -3
  26. package/dist/client/helpers/direction.js +0 -4
  27. package/dist/client/helpers/index.d.ts +0 -9
  28. package/dist/client/helpers/index.js +0 -9
  29. package/dist/client/helpers/is-rtl.d.ts +0 -2
  30. package/dist/client/helpers/is-rtl.js +0 -2
  31. package/dist/client/helpers/query-all.d.ts +0 -3
  32. package/dist/client/helpers/query-all.js +0 -5
  33. package/dist/client/helpers/query.d.ts +0 -3
  34. package/dist/client/helpers/query.js +0 -5
  35. package/dist/client/helpers/slots.d.ts +0 -6
  36. package/dist/client/helpers/slots.js +0 -15
  37. package/dist/client/helpers/styles.d.ts +0 -1
  38. package/dist/client/helpers/styles.js +0 -16
  39. package/dist/client/helpers/to-unit.d.ts +0 -1
  40. package/dist/client/helpers/to-unit.js +0 -7
  41. package/dist/client/index.d.ts +0 -3
  42. package/dist/client/index.js +0 -3
  43. package/dist/client/services/index.d.ts +0 -1
  44. package/dist/client/services/index.js +0 -1
  45. package/dist/client/services/link.d.ts +0 -4
  46. package/dist/client/services/link.js +0 -196
  47. package/dist/client/utils/append-to-method.d.ts +0 -2
  48. package/dist/client/utils/append-to-method.js +0 -7
  49. package/dist/client/utils/call.d.ts +0 -2
  50. package/dist/client/utils/call.js +0 -4
  51. package/dist/client/utils/define-property.d.ts +0 -1
  52. package/dist/client/utils/define-property.js +0 -1
  53. package/dist/client/utils/event.d.ts +0 -2
  54. package/dist/client/utils/event.js +0 -6
  55. package/dist/client/utils/get-members.d.ts +0 -2
  56. package/dist/client/utils/get-members.js +0 -5
  57. package/dist/client/utils/get-styles.d.ts +0 -2
  58. package/dist/client/utils/get-styles.js +0 -5
  59. package/dist/client/utils/host.d.ts +0 -2
  60. package/dist/client/utils/host.js +0 -4
  61. package/dist/client/utils/index.d.ts +0 -20
  62. package/dist/client/utils/index.js +0 -20
  63. package/dist/client/utils/is-event.d.ts +0 -1
  64. package/dist/client/utils/is-event.js +0 -3
  65. package/dist/client/utils/is-ready.d.ts +0 -2
  66. package/dist/client/utils/is-ready.js +0 -4
  67. package/dist/client/utils/is-server.d.ts +0 -1
  68. package/dist/client/utils/is-server.js +0 -3
  69. package/dist/client/utils/on-ready.d.ts +0 -2
  70. package/dist/client/utils/on-ready.js +0 -6
  71. package/dist/client/utils/parse-value.d.ts +0 -1
  72. package/dist/client/utils/parse-value.js +0 -15
  73. package/dist/client/utils/render.d.ts +0 -2
  74. package/dist/client/utils/render.js +0 -17
  75. package/dist/client/utils/request.d.ts +0 -2
  76. package/dist/client/utils/request.js +0 -25
  77. package/dist/client/utils/sync.d.ts +0 -1
  78. package/dist/client/utils/sync.js +0 -31
  79. package/dist/client/utils/task.d.ts +0 -6
  80. package/dist/client/utils/task.js +0 -46
  81. package/dist/client/utils/to-boolean.d.ts +0 -1
  82. package/dist/client/utils/to-boolean.js +0 -3
  83. package/dist/client/utils/to-event.d.ts +0 -1
  84. package/dist/client/utils/to-event.js +0 -3
  85. package/dist/client/utils/type-of.d.ts +0 -3
  86. package/dist/client/utils/type-of.js +0 -6
  87. package/dist/client/utils/update-attribute.d.ts +0 -1
  88. package/dist/client/utils/update-attribute.js +0 -7
  89. package/dist/compiler/compiler.d.ts +0 -7
  90. package/dist/compiler/compiler.js +0 -56
  91. package/dist/compiler/index.d.ts +0 -2
  92. package/dist/compiler/index.js +0 -2
  93. package/dist/compiler/plugins/attach.d.ts +0 -11
  94. package/dist/compiler/plugins/attach.js +0 -101
  95. package/dist/compiler/plugins/docs.d.ts +0 -11
  96. package/dist/compiler/plugins/docs.js +0 -320
  97. package/dist/compiler/plugins/extract.d.ts +0 -8
  98. package/dist/compiler/plugins/extract.js +0 -77
  99. package/dist/compiler/plugins/index.d.ts +0 -11
  100. package/dist/compiler/plugins/index.js +0 -11
  101. package/dist/compiler/plugins/parse.d.ts +0 -5
  102. package/dist/compiler/plugins/parse.js +0 -16
  103. package/dist/compiler/plugins/print.d.ts +0 -5
  104. package/dist/compiler/plugins/print.js +0 -11
  105. package/dist/compiler/plugins/react.proxy/index.d.ts +0 -1
  106. package/dist/compiler/plugins/react.proxy/index.js +0 -1
  107. package/dist/compiler/plugins/react.proxy/react.proxy.d.ts +0 -11
  108. package/dist/compiler/plugins/react.proxy/react.proxy.js +0 -121
  109. package/dist/compiler/plugins/react.proxy/templates/README.md.hbs +0 -1
  110. package/dist/compiler/plugins/react.proxy/templates/_.gitignore.hbs +0 -2
  111. package/dist/compiler/plugins/react.proxy/templates/package.json.hbs +0 -37
  112. package/dist/compiler/plugins/react.proxy/templates/rollup.config.js.hbs +0 -21
  113. package/dist/compiler/plugins/react.proxy/templates/src/components/index.ts.hbs +0 -17
  114. package/dist/compiler/plugins/react.proxy/templates/src/components/{{fileName}}.compact.ts.hbs +0 -18
  115. package/dist/compiler/plugins/react.proxy/templates/src/components/{{fileName}}.ts.hbs +0 -26
  116. package/dist/compiler/plugins/react.proxy/templates/src/index.ts.hbs +0 -1
  117. package/dist/compiler/plugins/react.proxy/templates/src/proxy.ts.hbs +0 -278
  118. package/dist/compiler/plugins/react.proxy/templates/tsconfig.json.hbs +0 -17
  119. package/dist/compiler/plugins/read.d.ts +0 -5
  120. package/dist/compiler/plugins/read.js +0 -13
  121. package/dist/compiler/plugins/sass.d.ts +0 -6
  122. package/dist/compiler/plugins/sass.js +0 -15
  123. package/dist/compiler/plugins/uhtml.d.ts +0 -5
  124. package/dist/compiler/plugins/uhtml.js +0 -59
  125. package/dist/compiler/plugins/validate.d.ts +0 -5
  126. package/dist/compiler/plugins/validate.js +0 -8
  127. package/dist/compiler/plugins/vscode.d.ts +0 -11
  128. package/dist/compiler/plugins/vscode.js +0 -83
  129. package/dist/compiler/utils/__dirname.d.ts +0 -1
  130. package/dist/compiler/utils/__dirname.js +0 -5
  131. package/dist/compiler/utils/get-initializer.d.ts +0 -2
  132. package/dist/compiler/utils/get-initializer.js +0 -10
  133. package/dist/compiler/utils/get-tags.d.ts +0 -6
  134. package/dist/compiler/utils/get-tags.js +0 -34
  135. package/dist/compiler/utils/get-type.d.ts +0 -2
  136. package/dist/compiler/utils/get-type.js +0 -69
  137. package/dist/compiler/utils/has-decorator.d.ts +0 -1
  138. package/dist/compiler/utils/has-decorator.js +0 -5
  139. package/dist/compiler/utils/index.d.ts +0 -10
  140. package/dist/compiler/utils/index.js +0 -10
  141. package/dist/compiler/utils/is-directory-empty.d.ts +0 -1
  142. package/dist/compiler/utils/is-directory-empty.js +0 -10
  143. package/dist/compiler/utils/print-type.d.ts +0 -1
  144. package/dist/compiler/utils/print-type.js +0 -69
  145. package/dist/compiler/utils/print.d.ts +0 -2
  146. package/dist/compiler/utils/print.js +0 -5
  147. package/dist/compiler/utils/render-template.d.ts +0 -1
  148. package/dist/compiler/utils/render-template.js +0 -25
  149. package/dist/compiler/utils/visitor.d.ts +0 -2
  150. package/dist/compiler/utils/visitor.js +0 -5
  151. package/dist/configs/constants.d.ts +0 -22
  152. package/dist/configs/constants.js +0 -28
  153. package/dist/runtime/index.d.ts +0 -1
  154. package/dist/runtime/index.js +0 -4
  155. package/dist/types/context.d.ts +0 -29
  156. package/dist/types/context.js +0 -1
  157. package/dist/types/index.d.ts +0 -3
  158. package/dist/types/index.js +0 -3
  159. package/dist/types/plugin.d.ts +0 -8
  160. package/dist/types/plugin.js +0 -1
  161. package/dist/types/plus-element.d.ts +0 -2
  162. package/dist/types/plus-element.js +0 -1
@@ -1,56 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- import logUpdate from 'log-update';
11
- const log = (namespace, message) => {
12
- logUpdate(`${new Date().toLocaleTimeString()} [@htmlplus/element]${namespace ? `[${namespace}]` : ''} ${message}`);
13
- };
14
- export default (...plugins) => {
15
- let global = {
16
- contexts: {}
17
- };
18
- const start = () => __awaiter(void 0, void 0, void 0, function* () {
19
- log(undefined, 'Starting.');
20
- for (const plugin of plugins) {
21
- if (!plugin.start)
22
- continue;
23
- global = (yield plugin.start(global)) || global;
24
- log(plugin.name, 'Started successfully.');
25
- }
26
- });
27
- const next = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
28
- const key = filePath.split(/[\/|\\]/g).pop();
29
- let context = {
30
- filePath
31
- };
32
- for (const plugin of plugins) {
33
- if (!plugin.next)
34
- continue;
35
- context = (yield plugin.next(context, global)) || context;
36
- log(`${key}:${plugin.name}`, 'Executed successfully.');
37
- }
38
- log(key, 'Executed successfully.');
39
- global.contexts[filePath] = context;
40
- return context;
41
- });
42
- const finish = () => __awaiter(void 0, void 0, void 0, function* () {
43
- for (const plugin of plugins) {
44
- if (!plugin.finish)
45
- continue;
46
- global = (yield plugin.finish(global)) || global;
47
- log(plugin.name, 'Finished successfully.');
48
- }
49
- log(undefined, 'Finished.');
50
- });
51
- return {
52
- start,
53
- next,
54
- finish
55
- };
56
- };
@@ -1,2 +0,0 @@
1
- export { default as default } from './compiler.js';
2
- export * from './plugins/index.js';
@@ -1,2 +0,0 @@
1
- export { default as default } from './compiler.js';
2
- export * from './plugins/index.js';
@@ -1,11 +0,0 @@
1
- import { Context } from '../../types/index.js';
2
- export interface AttachOptions {
3
- dependencies?: boolean;
4
- members?: boolean;
5
- styles?: boolean;
6
- typings?: boolean;
7
- }
8
- export declare const attach: (options: AttachOptions) => {
9
- name: string;
10
- next: (context: Context) => void;
11
- };
@@ -1,101 +0,0 @@
1
- import t from '@babel/types';
2
- import * as CONSTANTS from '../../configs/constants.js';
3
- import { visitor } from '../utils/index.js';
4
- const defaults = {
5
- dependencies: true,
6
- members: true,
7
- styles: true,
8
- typings: true
9
- };
10
- export const attach = (options) => {
11
- options = Object.assign({}, defaults, options);
12
- const name = 'attach';
13
- const next = (context) => {
14
- // TODO
15
- if (options.dependencies) {
16
- }
17
- if (options.styles && context.styleParsed)
18
- context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.stringLiteral(context.styleParsed), undefined, null, undefined, true));
19
- if (options.members) {
20
- context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_MEMBERS), t.objectExpression([
21
- ...context.classProperties.map((property) => {
22
- var _a, _b;
23
- const type = (_b = (_a = property.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation) === null || _b === void 0 ? void 0 : _b.type;
24
- const elements = [];
25
- switch (type) {
26
- case 'TSBooleanKeyword':
27
- elements.push(t.stringLiteral(CONSTANTS.TYPE_BOOLEAN));
28
- break;
29
- case 'TSStringKeyword':
30
- elements.push(t.stringLiteral(CONSTANTS.TYPE_STRING));
31
- break;
32
- case 'TSNumberKeyword':
33
- elements.push(t.stringLiteral(CONSTANTS.TYPE_NUMBER));
34
- break;
35
- default:
36
- elements.push(t.nullLiteral());
37
- break;
38
- }
39
- if (property.value)
40
- elements.push(property.value);
41
- return t.objectProperty(t.identifier(property.key['name']), t.arrayExpression(elements));
42
- }),
43
- ...context.classMethods.map((method) => {
44
- const elements = [t.stringLiteral(CONSTANTS.TYPE_FUNCTION)];
45
- return t.objectProperty(t.identifier(method.key['name']), t.arrayExpression(elements));
46
- })
47
- ]), undefined, undefined, undefined, true));
48
- }
49
- if (options.typings) {
50
- visitor(context.fileAST, {
51
- Program(path) {
52
- path.node.body.push(Object.assign(t.tsModuleDeclaration(t.identifier('global'), t.tsModuleBlock([
53
- t.tsInterfaceDeclaration(t.identifier(context.componentInterfaceName), null, [], t.tsInterfaceBody([
54
- ...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
55
- optional: property.optional,
56
- leadingComments: property.leadingComments
57
- }))
58
- ])),
59
- t.variableDeclaration('var', [
60
- t.variableDeclarator(Object.assign(t.identifier(context.componentInterfaceName), {
61
- typeAnnotation: t.tSTypeAnnotation(t.tSTypeLiteral([
62
- t.tSPropertySignature(t.identifier('prototype'), t.tsTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName)))),
63
- t.tSConstructSignatureDeclaration(null, [], t.tSTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName))))
64
- ]))
65
- }))
66
- ]),
67
- t.tsInterfaceDeclaration(t.identifier('HTMLElementTagNameMap'), null, [], t.tsInterfaceBody([
68
- t.tSPropertySignature(t.stringLiteral(context.componentTag), t.tSTypeAnnotation(t.tSIntersectionType([t.tSTypeReference(t.identifier(context.componentInterfaceName))])))
69
- ]))
70
- ])), {
71
- declare: true,
72
- global: true
73
- }));
74
- path.node.body.push(t.exportNamedDeclaration(t.tsInterfaceDeclaration(
75
- // TODO
76
- t.identifier(context.componentClassName + 'JSX'), null, [], t.tsInterfaceBody([
77
- ...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
78
- optional: property.optional,
79
- leadingComments: property.leadingComments
80
- })),
81
- ...context.classEvents.map((event) => {
82
- var _a, _b;
83
- return Object.assign(t.tSPropertySignature(event.key, t.tsTypeAnnotation(t.tsFunctionType(undefined, [
84
- Object.assign({}, t.identifier('event'), {
85
- typeAnnotation: t.tsTypeAnnotation(t.tsTypeReference(t.identifier('CustomEvent'), (_b = (_a = event.typeAnnotation) === null || _a === void 0 ? void 0 : _a['typeAnnotation']) === null || _b === void 0 ? void 0 : _b.typeParameters))
86
- })
87
- ], t.tsTypeAnnotation(t.tsVoidKeyword())))), {
88
- optional: true,
89
- leadingComments: event.leadingComments
90
- });
91
- })
92
- ]))));
93
- }
94
- });
95
- }
96
- };
97
- return {
98
- name,
99
- next
100
- };
101
- };
@@ -1,11 +0,0 @@
1
- import { Context } from '../../types/index.js';
2
- export interface DocsOptions {
3
- dist: string;
4
- prefix: string;
5
- }
6
- export declare const docs: (options: DocsOptions) => {
7
- name: string;
8
- start: (global: any) => void;
9
- next: (context: Context, global: any) => void;
10
- finish: (global: any) => void;
11
- };
@@ -1,320 +0,0 @@
1
- import { capitalCase, paramCase } from 'change-case';
2
- import fs from 'fs';
3
- // import glob from 'glob';
4
- import path from 'path';
5
- import { getInitializer, getTags, getType, printType } from '../utils/index.js';
6
- export const docs = (options) => {
7
- const name = 'docs';
8
- const start = (global) => {
9
- global.docs = {
10
- prefix: options.prefix,
11
- components: []
12
- };
13
- };
14
- const next = (context, global) => {
15
- var _a;
16
- const tags = getTags(context.class);
17
- const development = tags.some((tag) => tag.key == 'development');
18
- const experimental = tags.some((tag) => tag.key == 'experimental');
19
- const externals = fs.existsSync(path.resolve(context.directoryPath || '', 'externals'));
20
- const examples = (() => {
21
- const items = [];
22
- const source = path.join(context.directoryPath || '', 'examples');
23
- if (!fs.existsSync(source))
24
- return items;
25
- return fs
26
- .readdirSync(source)
27
- .filter((file) => file.endsWith('.md'))
28
- .map((file) => {
29
- const item = {};
30
- const regex = /```\w+\s\[\w+(:\w+)?\]\s[\S\s]*?```/g;
31
- const filePath = path.join(source, file);
32
- const content = fs.readFileSync(filePath, 'utf8');
33
- item.key = path.basename(filePath).replace('.md', '');
34
- item.title = capitalCase(item.key);
35
- item.readme = content.replace(regex, '').trim();
36
- item.codes = (content.match(regex) || []).map((section) => {
37
- try {
38
- const lines = section.split('\n');
39
- const key = ((lines[0].match(/\[\w+(:\w+)?\]/) || []).shift() || '').replace('[', '').replace(']', '');
40
- const type = ((lines[0].match(/```\w+/) || []).pop() || '').replace('```', '');
41
- const value = lines.slice(1, -1).join('\n');
42
- return {
43
- key,
44
- type,
45
- value
46
- };
47
- }
48
- catch (_a) { }
49
- });
50
- return item;
51
- });
52
- })();
53
- const readme = (() => {
54
- try {
55
- const source = path.resolve(context.directoryPath || '', `${context.fileName}.md`);
56
- return fs.readFileSync(source, 'utf8');
57
- }
58
- catch (_a) { }
59
- })();
60
- const description = (() => {
61
- const content = readme || '';
62
- if (!content.startsWith('# '))
63
- return '';
64
- const sections = content.split('\n');
65
- for (let i = 1; i < sections.length; i++) {
66
- const section = sections[i].trim();
67
- if (!section)
68
- continue;
69
- return section;
70
- }
71
- return '';
72
- })();
73
- const properties = (context.classProperties || []).map((property) => {
74
- var _a;
75
- const tags = getTags(property);
76
- const name = property.key['name'];
77
- const attribute = paramCase(name);
78
- // TODO
79
- const initializer = getInitializer(property.value);
80
- // TODO
81
- const reflect = (() => {
82
- if (!property.decorators)
83
- return false;
84
- try {
85
- for (const decorator of property.decorators) {
86
- for (const argument of decorator.expression['arguments']) {
87
- for (const property of argument.properties) {
88
- if (property.key.name != 'reflect')
89
- continue;
90
- if (property.value.type != 'BooleanLiteral')
91
- continue;
92
- if (!property.value.value)
93
- continue;
94
- return true;
95
- }
96
- }
97
- }
98
- }
99
- catch (_a) { }
100
- return false;
101
- })();
102
- const required = !property.optional;
103
- // TODO
104
- const { type, members } = (() => {
105
- const ast = getType(context.fileAST, (property.typeAnnotation || {})['typeAnnotation'], {
106
- directory: context.directoryPath
107
- });
108
- return printType(ast);
109
- })();
110
- const experimental = tags.some((tag) => tag.key == 'experimental');
111
- const description = (_a = tags.find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
112
- const model = tags.some((tag) => tag.key == 'model');
113
- return {
114
- name,
115
- attribute,
116
- initializer,
117
- reflect,
118
- required,
119
- type,
120
- experimental,
121
- description,
122
- members,
123
- model
124
- };
125
- });
126
- const parts = tags
127
- .filter((tag) => tag.key == 'part')
128
- .map((tag) => {
129
- var _a;
130
- const sections = ((_a = tag.value) === null || _a === void 0 ? void 0 : _a.split('-')) || [];
131
- const name = sections[0].trim();
132
- const description = sections.slice(1).join('-').trim();
133
- return {
134
- name,
135
- description
136
- };
137
- });
138
- const methods = (context.classMethods || []).map((method) => {
139
- var _a;
140
- const tags = getTags(method);
141
- const name = method.key['name'];
142
- const experimental = tags.some((tag) => tag.key == 'experimental');
143
- // TODO
144
- // const params = printType(getType(
145
- // context.ast,
146
- // method.params,
147
- // {
148
- // directory: context.directory,
149
- // }
150
- // ));
151
- // console.log(111, params)
152
- // TODO: returnType
153
- const type = (() => {
154
- try {
155
- return printType(getType(context.fileAST, (method.returnType || {})['typeAnnotation'], {
156
- directory: context.directoryPath
157
- }));
158
- }
159
- catch (_a) { }
160
- })();
161
- // TODO
162
- const signature = `${method.key['name']}(${''}) => ${type}`;
163
- const description = (_a = tags.find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
164
- // TODO
165
- const parameters = [
166
- // {
167
- // "name": "offsetX",
168
- // "description": "Moving size (px) in the `horizontal` direction. Use `null` to ignore this."
169
- // },
170
- // {
171
- // "name": "offsetY",
172
- // "description": "Moving size (px) in the `vertical` direction. Use `null` to ignore this."
173
- // }
174
- ];
175
- return {
176
- name,
177
- experimental,
178
- type,
179
- signature,
180
- description,
181
- parameters
182
- };
183
- });
184
- const slots = tags
185
- .filter((tag) => tag.key == 'slot')
186
- .map((tag) => {
187
- var _a;
188
- const sections = ((_a = tag.value) === null || _a === void 0 ? void 0 : _a.split('-')) || [];
189
- const name = sections[0].trim();
190
- const description = sections.slice(1).join('-').trim();
191
- return {
192
- name,
193
- description
194
- };
195
- });
196
- const events = (context.classEvents || []).map((event) => {
197
- var _a;
198
- const tags = getTags(event);
199
- const name = event.key['name'];
200
- const cancelable = (() => {
201
- if (!event.decorators)
202
- return false;
203
- try {
204
- for (const decorator of event.decorators) {
205
- for (const argument of decorator.expression['arguments']) {
206
- for (const property of argument.properties) {
207
- if (property.key.name != 'cancelable')
208
- continue;
209
- if (property.value.type != 'BooleanLiteral')
210
- continue;
211
- if (!property.value.value)
212
- continue;
213
- return true;
214
- }
215
- }
216
- }
217
- }
218
- catch (_a) { }
219
- return false;
220
- })();
221
- // TODO
222
- const detail = (() => {
223
- try {
224
- return printType(getType(context.fileAST, (event.typeAnnotation || {})['typeAnnotation'].typeParameters.params[0], {
225
- directory: context.directoryPath
226
- }));
227
- }
228
- catch (_a) { }
229
- })();
230
- const experimental = tags.some((tag) => tag.key == 'experimental');
231
- const description = (_a = tags.find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
232
- const model = tags.some((tag) => tag.key == 'model');
233
- return {
234
- name,
235
- cancelable,
236
- detail,
237
- experimental,
238
- description,
239
- model
240
- };
241
- });
242
- const styles = (() => {
243
- const styles = [];
244
- try {
245
- fs.readFileSync(context.stylePath || '', 'utf8')
246
- .split('@prop')
247
- .slice(1)
248
- .map((section) => {
249
- var _a;
250
- let [description, name] = section.split(/\n/);
251
- name = name.split(':').slice(0, -1).join(':').trim();
252
- description = description.trim();
253
- let [initializer] = ((_a = context.styleParsed) === null || _a === void 0 ? void 0 : _a.split(name).slice(1, 2)) || [];
254
- if (initializer)
255
- initializer = initializer.split(/;|}/)[0].replace(':', '').trim();
256
- styles.push({
257
- name,
258
- initializer,
259
- description
260
- });
261
- });
262
- }
263
- catch (_a) { }
264
- return styles;
265
- })();
266
- // TODO
267
- const lastModified = 0;
268
- // glob
269
- // .sync(path.join(context.directory, '**/*.*'))
270
- // .reduce((result, file) => {
271
- // const state = fs.statSync(file);
272
- // return result > state.mtime ? result : state.mtime
273
- // }, 0);
274
- const group = ((_a = tags.find((tag) => tag.key == 'group')) === null || _a === void 0 ? void 0 : _a.value) || null;
275
- const main = (group && context.componentKey == group) || !group;
276
- // TODO
277
- // context.types = (() => {
278
- // return [];
279
- // })();
280
- global.docs.components.push({
281
- key: context.componentKey,
282
- tag: context.componentTag,
283
- title: capitalCase(context.componentKey || ''),
284
- main,
285
- group,
286
- development,
287
- experimental,
288
- // TODO
289
- deprecated: false,
290
- externals,
291
- lastModified,
292
- // TODO
293
- tags: [],
294
- // TODO
295
- source: context.componentKey,
296
- description,
297
- readme,
298
- properties,
299
- slots,
300
- events,
301
- styles,
302
- parts,
303
- methods,
304
- examples
305
- });
306
- };
307
- const finish = (global) => {
308
- global.docs.components = global.docs.components.sort((a, b) => (a.key > b.key ? 1 : -1));
309
- // TODO
310
- // fs.ensureDirSync(path.dirname(options.dist));
311
- // TODO
312
- // fs.writeJSONSync(options.dist, global.docs, { replacer: null, spaces: 2 });
313
- };
314
- return {
315
- name,
316
- start,
317
- next,
318
- finish
319
- };
320
- };
@@ -1,8 +0,0 @@
1
- import { Context } from '../../types/index.js';
2
- export interface ExtractOptions {
3
- prefix?: string;
4
- }
5
- export declare const extract: (options?: ExtractOptions | undefined) => {
6
- name: string;
7
- next: (context: Context) => void;
8
- };
@@ -1,77 +0,0 @@
1
- import * as t from '@babel/types';
2
- import { pascalCase, paramCase } from 'change-case';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import * as CONSTANTS from '../../configs/constants.js';
6
- import { hasDecorator, visitor } from '../utils/index.js';
7
- export const extract = (options) => {
8
- const name = 'extract';
9
- const next = (context) => {
10
- var _a, _b;
11
- visitor(context.fileAST, {
12
- ClassDeclaration: {
13
- exit(path) {
14
- var _a, _b;
15
- context.class = path.node;
16
- context.classMembers = ((_b = (_a = context.class) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.body) || [];
17
- path.skip();
18
- }
19
- },
20
- Decorator(path) {
21
- var _a;
22
- const name = (_a = path.node.expression.callee) === null || _a === void 0 ? void 0 : _a.name;
23
- // TODO
24
- if (CONSTANTS.DECORATOR_ELEMENT == name) {
25
- const [argument] = path.node.expression.arguments;
26
- if (argument) {
27
- context.componentTag = argument === null || argument === void 0 ? void 0 : argument.value;
28
- return;
29
- }
30
- context.componentTag = paramCase(path.parent.id.name);
31
- if (options === null || options === void 0 ? void 0 : options.prefix)
32
- context.componentTag = options.prefix + '-' + context.componentTag;
33
- path.replaceWith(t.decorator(t.callExpression(t.identifier(name), [
34
- t.stringLiteral(context.componentTag),
35
- ...path.node.expression.arguments.slice(1)
36
- ])));
37
- return;
38
- }
39
- }
40
- });
41
- context.directoryPath = path.dirname(context.filePath);
42
- context.directoryName = path.basename(context.directoryPath);
43
- context.fileExtension = path.extname(context.filePath);
44
- context.fileName = path.basename(context.filePath, context.fileExtension);
45
- context.className = (_b = (_a = context.class) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.name;
46
- // TODO
47
- // context.componentKey = paramCase(context.className);
48
- context.componentClassName = pascalCase(context.componentTag.split('-').slice(1).join('-'));
49
- context.componentInterfaceName = `HTML${context.componentClassName}Element`;
50
- // TODO
51
- // const componentClassName = "DialogBody"; [OK]
52
- // const componentInterfaceName = "HTMLDialogBodyElement"; [OK]
53
- // const componentTag = "plus-dialog-body"; [OK]
54
- // const componentClassNameInCategory = "Body"; [RAW]
55
- // const componentKey = "dialog-body-1"; [RAW]
56
- // const fileName = "dialogBodyNew"; [OK]
57
- // const className = "DialogBody1"; [OK]
58
- // const category = "Dialog"; [RAW]
59
- (() => {
60
- const stylePath = path.join(context.directoryPath, `${context.fileName}.scss`);
61
- if (!fs.existsSync(stylePath))
62
- return;
63
- context.stylePath = stylePath;
64
- })();
65
- context.classEvents = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_EVENT));
66
- context.classMethods = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_METHOD));
67
- context.classProperties = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_PROPERTY));
68
- context.classStates = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_STATE));
69
- context.classHasMount = (context.classMembers || []).some((member) => member['key'].name == CONSTANTS.LIFECYCLE_CONNECTED);
70
- context.classHasUnmount = (context.classMembers || []).some((member) => member['key'].name == CONSTANTS.LIFECYCLE_DISCONNECTED);
71
- context.classRender = (context.classMembers || []).find((member) => member['key'].name == CONSTANTS.METHOD_RENDER);
72
- };
73
- return {
74
- name,
75
- next
76
- };
77
- };
@@ -1,11 +0,0 @@
1
- export * from './react.proxy/index.js';
2
- export * from './attach.js';
3
- export * from './docs.js';
4
- export * from './extract.js';
5
- export * from './parse.js';
6
- export * from './print.js';
7
- export * from './read.js';
8
- export * from './sass.js';
9
- export * from './uhtml.js';
10
- export * from './validate.js';
11
- export * from './vscode.js';
@@ -1,11 +0,0 @@
1
- export * from './react.proxy/index.js';
2
- export * from './attach.js';
3
- export * from './docs.js';
4
- export * from './extract.js';
5
- export * from './parse.js';
6
- export * from './print.js';
7
- export * from './read.js';
8
- export * from './sass.js';
9
- export * from './uhtml.js';
10
- export * from './validate.js';
11
- export * from './vscode.js';
@@ -1,5 +0,0 @@
1
- import { Context } from '../../types/index.js';
2
- export declare const parse: () => {
3
- name: string;
4
- next: (context: Context) => void;
5
- };
@@ -1,16 +0,0 @@
1
- import { parse as parser } from '@babel/parser';
2
- export const parse = () => {
3
- const name = 'parse';
4
- const next = (context) => {
5
- if (!!context.fileAST)
6
- return;
7
- context.fileAST = parser(context.fileContent, {
8
- allowImportExportEverywhere: true,
9
- plugins: ['jsx', 'typescript', 'decorators-legacy']
10
- });
11
- };
12
- return {
13
- name,
14
- next
15
- };
16
- };
@@ -1,5 +0,0 @@
1
- import { Context } from '../../types/index.js';
2
- export declare const print: () => {
3
- name: string;
4
- next: (context: Context) => void;
5
- };
@@ -1,11 +0,0 @@
1
- import { print as core } from '../utils/index.js';
2
- export const print = () => {
3
- const name = 'print';
4
- const next = (context) => {
5
- context.script = core(context.fileAST);
6
- };
7
- return {
8
- name,
9
- next
10
- };
11
- };
@@ -1 +0,0 @@
1
- export * from './react.proxy.js';
@@ -1 +0,0 @@
1
- export * from './react.proxy.js';