@htmlplus/element 0.3.3 → 0.4.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 (106) hide show
  1. package/client/decorators/attributes.js +3 -3
  2. package/client/decorators/element.js +8 -4
  3. package/client/decorators/event.js +2 -3
  4. package/client/decorators/listen.js +2 -1
  5. package/client/decorators/method.js +4 -5
  6. package/client/decorators/property.d.ts +0 -4
  7. package/client/decorators/property.js +37 -43
  8. package/client/decorators/state.js +17 -26
  9. package/client/decorators/watch.d.ts +7 -1
  10. package/client/decorators/watch.js +26 -9
  11. package/client/helpers/index.d.ts +3 -3
  12. package/client/helpers/index.js +3 -3
  13. package/client/helpers/{is-rtl.d.ts → isRTL.d.ts} +0 -0
  14. package/client/helpers/{is-rtl.js → isRTL.js} +0 -0
  15. package/client/helpers/{query-all.d.ts → queryAll.d.ts} +0 -0
  16. package/client/helpers/{query-all.js → queryAll.js} +0 -0
  17. package/client/helpers/slots.js +1 -1
  18. package/client/helpers/styles.js +2 -1
  19. package/client/helpers/{to-unit.d.ts → toUnit.d.ts} +0 -0
  20. package/client/helpers/{to-unit.js → toUnit.js} +0 -0
  21. package/client/utils/{append-to-method.d.ts → appendToMethod.d.ts} +0 -0
  22. package/client/utils/{append-to-method.js → appendToMethod.js} +0 -0
  23. package/client/utils/{define-property.d.ts → defineProperty.d.ts} +0 -0
  24. package/client/utils/{define-property.js → defineProperty.js} +0 -0
  25. package/client/utils/event.d.ts +5 -2
  26. package/client/utils/event.js +7 -4
  27. package/client/utils/{get-members.d.ts → getMembers.d.ts} +0 -0
  28. package/client/utils/{get-members.js → getMembers.js} +0 -0
  29. package/client/utils/{get-styles.d.ts → getStyles.d.ts} +0 -0
  30. package/client/utils/{get-styles.js → getStyles.js} +0 -0
  31. package/client/utils/index.d.ts +11 -14
  32. package/client/utils/index.js +11 -14
  33. package/client/utils/{is-event.d.ts → isEvent.d.ts} +0 -0
  34. package/client/utils/{is-event.js → isEvent.js} +0 -0
  35. package/client/utils/{is-server.d.ts → isServer.d.ts} +0 -0
  36. package/client/utils/{is-server.js → isServer.js} +0 -0
  37. package/client/utils/{parse-value.d.ts → parseValue.d.ts} +0 -0
  38. package/client/utils/{parse-value.js → parseValue.js} +2 -2
  39. package/client/utils/request.d.ts +3 -1
  40. package/client/utils/request.js +15 -5
  41. package/client/utils/sync.js +3 -3
  42. package/client/utils/{to-boolean.d.ts → toBoolean.d.ts} +0 -0
  43. package/client/utils/{to-boolean.js → toBoolean.js} +0 -0
  44. package/client/utils/{to-event.d.ts → toEvent.d.ts} +0 -0
  45. package/client/utils/{to-event.js → toEvent.js} +0 -0
  46. package/client/utils/{type-of.d.ts → typeOf.d.ts} +0 -0
  47. package/client/utils/{type-of.js → typeOf.js} +0 -0
  48. package/client/utils/{update-attribute.d.ts → updateAttribute.d.ts} +0 -0
  49. package/client/utils/{update-attribute.js → updateAttribute.js} +0 -0
  50. package/client/vendor/uhtml.d.ts +22 -0
  51. package/client/vendor/uhtml.js +700 -0
  52. package/compiler/compiler.js +39 -22
  53. package/compiler/plugins/customElement.d.ts +4 -1
  54. package/compiler/plugins/customElement.js +96 -77
  55. package/compiler/plugins/customElementReact/customElementReact.d.ts +1 -1
  56. package/compiler/plugins/customElementReact/customElementReact.js +12 -8
  57. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +4 -4
  58. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +1 -1
  59. package/compiler/plugins/{docs.d.ts → document.d.ts} +3 -4
  60. package/compiler/plugins/document.js +254 -0
  61. package/compiler/plugins/external.d.ts +9 -0
  62. package/compiler/plugins/external.js +25 -0
  63. package/compiler/plugins/extract.js +3 -11
  64. package/compiler/plugins/index.d.ts +2 -0
  65. package/compiler/plugins/index.js +2 -0
  66. package/compiler/plugins/style.js +1 -1
  67. package/compiler/utils/{get-initializer.d.ts → getInitializer.d.ts} +0 -0
  68. package/compiler/utils/{get-initializer.js → getInitializer.js} +0 -0
  69. package/compiler/utils/{get-type.d.ts → getType.d.ts} +0 -0
  70. package/compiler/utils/{get-type.js → getType.js} +0 -0
  71. package/compiler/utils/getTypeReference.d.ts +2 -0
  72. package/compiler/utils/getTypeReference.js +33 -0
  73. package/compiler/utils/{has-decorator.d.ts → hasDecorator.d.ts} +0 -0
  74. package/compiler/utils/{has-decorator.js → hasDecorator.js} +0 -0
  75. package/compiler/utils/index.d.ts +8 -7
  76. package/compiler/utils/index.js +8 -7
  77. package/compiler/utils/{is-directory-empty.d.ts → isDirectoryEmpty.d.ts} +0 -0
  78. package/compiler/utils/{is-directory-empty.js → isDirectoryEmpty.js} +0 -0
  79. package/compiler/utils/{print-type.d.ts → printType.d.ts} +0 -0
  80. package/compiler/utils/{print-type.js → printType.js} +0 -0
  81. package/compiler/utils/{render-template.d.ts → renderTemplate.d.ts} +0 -0
  82. package/compiler/utils/{render-template.js → renderTemplate.js} +0 -0
  83. package/compiler/utils/tags.d.ts +13 -0
  84. package/compiler/utils/tags.js +53 -0
  85. package/constants/index.d.ts +0 -1
  86. package/constants/index.js +0 -1
  87. package/package.json +14 -17
  88. package/types/context.d.ts +6 -0
  89. package/types/index.d.ts +1 -1
  90. package/types/index.js +1 -1
  91. package/types/plugin.d.ts +4 -3
  92. package/types/{plus-element.d.ts → plusElement.d.ts} +0 -0
  93. package/types/{plus-element.js → plusElement.js} +0 -0
  94. package/client/utils/is-ready.d.ts +0 -2
  95. package/client/utils/is-ready.js +0 -4
  96. package/client/utils/on-ready.d.ts +0 -2
  97. package/client/utils/on-ready.js +0 -6
  98. package/client/utils/render.d.ts +0 -2
  99. package/client/utils/render.js +0 -19
  100. package/compiler/plugins/componentDependencyResolver.d.ts +0 -5
  101. package/compiler/plugins/componentDependencyResolver.js +0 -40
  102. package/compiler/plugins/docs.js +0 -320
  103. package/compiler/utils/get-tags.d.ts +0 -6
  104. package/compiler/utils/get-tags.js +0 -34
  105. package/runtime/index.d.ts +0 -1
  106. package/runtime/index.js +0 -4
@@ -0,0 +1,254 @@
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, getTag, getTags, getTypeReference, hasTag, parseTag, print } from '../utils/index.js';
6
+ export const document = (options) => {
7
+ const name = 'document';
8
+ const start = (global) => {
9
+ global.document = {
10
+ components: []
11
+ };
12
+ };
13
+ const next = (context, global) => {
14
+ var _a;
15
+ const events = context.classEvents.map((event) => {
16
+ var _a, _b, _c;
17
+ const isCancelable = (() => {
18
+ if (!event.decorators)
19
+ return false;
20
+ try {
21
+ for (const decorator of event.decorators) {
22
+ for (const argument of decorator.expression['arguments']) {
23
+ for (const property of argument.properties) {
24
+ if (property.key.name != 'cancelable')
25
+ continue;
26
+ if (property.value.type != 'BooleanLiteral')
27
+ continue;
28
+ if (!property.value.value)
29
+ continue;
30
+ return true;
31
+ }
32
+ }
33
+ }
34
+ }
35
+ catch (_a) { }
36
+ return false;
37
+ })();
38
+ const description = (_a = getTags(event).find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
39
+ const detail = print((_b = event.typeAnnotation) === null || _b === void 0 ? void 0 : _b['typeAnnotation']);
40
+ const detailReference = getTypeReference(context.fileAST, (_c = event.typeAnnotation) === null || _c === void 0 ? void 0 : _c['typeAnnotation'].typeParameters.params[0]);
41
+ const isExperimental = hasTag(event, 'experimental');
42
+ const isModel = hasTag(event, 'model');
43
+ const name = event.key['name'];
44
+ const tags = getTags(event);
45
+ return {
46
+ description,
47
+ detail,
48
+ detailReference,
49
+ isCancelable,
50
+ isExperimental,
51
+ isModel,
52
+ name,
53
+ tags
54
+ };
55
+ });
56
+ const group = (_a = getTag(context.class, 'group')) === null || _a === void 0 ? void 0 : _a.value;
57
+ const isDeprecated = hasTag(context.class, 'deprecated');
58
+ const isExperimental = hasTag(context.class, 'experimental');
59
+ const lastModified = glob
60
+ .sync(path.join(context.directoryPath, '**/*.*'))
61
+ .map((file) => fs.statSync(file).mtime)
62
+ .sort((a, b) => (a > b ? 1 : -1))
63
+ .pop();
64
+ const methods = context.classMethods.map((method) => {
65
+ var _a, _b, _c;
66
+ const description = (_a = getTags(method).find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
67
+ const isAsync = method.async;
68
+ const isDeprecated = hasTag(method, 'deprecated');
69
+ const isExperimental = hasTag(method, 'experimental');
70
+ const name = method.key['name'];
71
+ const returns = print((_b = method.returnType) === null || _b === void 0 ? void 0 : _b['typeAnnotation']) || 'void';
72
+ const returnsReference = getTypeReference(context.fileAST, (_c = method.returnType) === null || _c === void 0 ? void 0 : _c['typeAnnotation']);
73
+ const tags = getTags(method);
74
+ // TODO
75
+ const parameters = method.params.map((param) => {
76
+ var _a, _b, _c;
77
+ return ({
78
+ description: (_a = getTags(method, 'param')
79
+ .map((tag) => parseTag(tag, ' '))
80
+ .find((tag) => tag.name == param['name'])) === null || _a === void 0 ? void 0 : _a.description,
81
+ isOptional: !!param['optional'],
82
+ name: param['name'],
83
+ type: print((_b = param === null || param === void 0 ? void 0 : param['typeAnnotation']) === null || _b === void 0 ? void 0 : _b.typeAnnotation) || undefined,
84
+ typeReference: getTypeReference(context.fileAST, (_c = param === null || param === void 0 ? void 0 : param['typeAnnotation']) === null || _c === void 0 ? void 0 : _c.typeAnnotation)
85
+ });
86
+ });
87
+ const signature = [
88
+ method.key['name'],
89
+ '(',
90
+ parameters
91
+ .map((parameter) => {
92
+ var _a;
93
+ let string = '';
94
+ string += parameter.name;
95
+ string += parameter.isOptional ? '?' : '';
96
+ string += parameter.type ? ': ' : '';
97
+ string += (_a = parameter.type) !== null && _a !== void 0 ? _a : '';
98
+ return string;
99
+ })
100
+ .join(', '),
101
+ ')',
102
+ ' => ',
103
+ returns
104
+ ].join('');
105
+ return {
106
+ description,
107
+ isAsync,
108
+ isDeprecated,
109
+ isExperimental,
110
+ name,
111
+ returns,
112
+ returnsReference,
113
+ tags,
114
+ parameters,
115
+ signature
116
+ };
117
+ });
118
+ const parts = getTags(context.class, 'part').map((tag) => parseTag(tag));
119
+ const properties = context.classProperties.map((property) => {
120
+ var _a, _b, _c;
121
+ const attribute = paramCase(property.key['name']);
122
+ const description = (_a = getTags(property).find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
123
+ // TODO
124
+ const hasReflect = (() => {
125
+ if (!property.decorators)
126
+ return false;
127
+ try {
128
+ for (const decorator of property.decorators) {
129
+ for (const argument of decorator.expression['arguments']) {
130
+ for (const property of argument.properties) {
131
+ if (property.key.name != 'reflect')
132
+ continue;
133
+ if (property.value.type != 'BooleanLiteral')
134
+ continue;
135
+ if (!property.value.value)
136
+ continue;
137
+ return true;
138
+ }
139
+ }
140
+ }
141
+ }
142
+ catch (_a) { }
143
+ return false;
144
+ })();
145
+ // TODO
146
+ const initializer = getInitializer(property.value);
147
+ const isDeprecated = hasTag(property, 'deprecated');
148
+ const isExperimental = hasTag(property, 'experimental');
149
+ const isModel = hasTag(property, 'model');
150
+ const isRequired = !property.optional;
151
+ const name = property.key['name'];
152
+ const tags = getTags(property);
153
+ const type = print((_b = property.typeAnnotation) === null || _b === void 0 ? void 0 : _b['typeAnnotation']);
154
+ const typeReference = getTypeReference(context.fileAST, (_c = property.typeAnnotation) === null || _c === void 0 ? void 0 : _c['typeAnnotation']);
155
+ return {
156
+ attribute,
157
+ description,
158
+ hasReflect,
159
+ initializer,
160
+ isDeprecated,
161
+ isExperimental,
162
+ isModel,
163
+ isRequired,
164
+ name,
165
+ tags,
166
+ type,
167
+ typeReference
168
+ };
169
+ });
170
+ const readme = (() => {
171
+ try {
172
+ const source = path.join(context.directoryPath, `${context.fileName}.md`);
173
+ return fs.readFileSync(source, 'utf8');
174
+ }
175
+ catch (_a) { }
176
+ })();
177
+ const readmeDescription = (() => {
178
+ const content = readme || '';
179
+ if (!content.startsWith('# '))
180
+ return '';
181
+ const sections = content.split('\n');
182
+ for (let i = 1; i < sections.length; i++) {
183
+ const section = sections[i].trim();
184
+ if (!section)
185
+ continue;
186
+ return section;
187
+ }
188
+ return '';
189
+ })();
190
+ const slots = getTags(context.class, 'slot').map((tag) => parseTag(tag));
191
+ // TODO
192
+ const styles = (() => {
193
+ if (!context.stylePath)
194
+ return [];
195
+ return fs
196
+ .readFileSync(context.stylePath, 'utf8')
197
+ .split('@prop')
198
+ .slice(1)
199
+ .map((section) => {
200
+ var _a;
201
+ let [description, name] = section.split(/\n/);
202
+ name = name.split(':').slice(0, -1).join(':').trim();
203
+ description = description.trim();
204
+ let [initializer] = ((_a = context.styleParsed) === null || _a === void 0 ? void 0 : _a.split(name).slice(1, 2)) || [];
205
+ if (initializer)
206
+ initializer = initializer.split(/;|}/)[0].replace(':', '').trim();
207
+ return {
208
+ description,
209
+ initializer,
210
+ name
211
+ };
212
+ });
213
+ })();
214
+ const tag = context.componentTag;
215
+ const tags = getTags(context.class);
216
+ const title = capitalCase(context.componentKey);
217
+ global.document.components.push({
218
+ // TODO
219
+ // main
220
+ // development
221
+ // source
222
+ events,
223
+ group,
224
+ isDeprecated,
225
+ isExperimental,
226
+ key: context.componentKey,
227
+ lastModified,
228
+ methods,
229
+ parts,
230
+ properties,
231
+ readme,
232
+ readmeDescription,
233
+ slots,
234
+ styles,
235
+ tag,
236
+ tags,
237
+ title
238
+ });
239
+ };
240
+ const finish = (global) => {
241
+ const dirname = path.dirname(options.destination);
242
+ global.document.components = global.document.components.sort((a, b) => (a.title > b.title ? 1 : -1));
243
+ if (!fs.existsSync(dirname))
244
+ fs.mkdirSync(dirname, { recursive: true });
245
+ JSON.stringify(global.document, null, 2);
246
+ fs.writeFileSync(options.destination, JSON.stringify(global.document, null, 2), 'utf8');
247
+ };
248
+ return {
249
+ name,
250
+ start,
251
+ next,
252
+ finish
253
+ };
254
+ };
@@ -0,0 +1,9 @@
1
+ import { Context } from '../../types/index.js';
2
+ export declare type ExternalOptions = {
3
+ source?: (context: Context) => string;
4
+ destination: (context: Context) => string;
5
+ };
6
+ export declare const external: (options: ExternalOptions) => {
7
+ name: string;
8
+ next: (context: Context) => void;
9
+ };
@@ -0,0 +1,25 @@
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
+ };
@@ -43,18 +43,10 @@ export const extract = (options) => {
43
43
  context.fileName = path.basename(context.filePath, context.fileExtension);
44
44
  context.className = (_b = (_a = context.class) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.name;
45
45
  // TODO
46
- // context.componentKey = paramCase(context.className);
47
- context.componentClassName = pascalCase(context.componentTag.split('-').slice(1).join('-'));
46
+ context.componentClassName = pascalCase(context.componentTag);
47
+ context.componentClassNamePrune = pascalCase(context.componentTag.split('-').slice(1).join('-'));
48
48
  context.componentInterfaceName = `HTML${context.componentClassName}Element`;
49
- // TODO
50
- // const componentClassName = "DialogBody"; [OK]
51
- // const componentInterfaceName = "HTMLDialogBodyElement"; [OK]
52
- // const componentTag = "plus-dialog-body"; [OK]
53
- // const componentClassNameInCategory = "Body"; [RAW]
54
- // const componentKey = "dialog-body-1"; [RAW]
55
- // const fileName = "dialogBodyNew"; [OK]
56
- // const className = "DialogBody1"; [OK]
57
- // const category = "Dialog"; [RAW]
49
+ context.componentKey = paramCase(context.componentClassNamePrune);
58
50
  context.classEvents = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_EVENT));
59
51
  context.classMethods = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_METHOD));
60
52
  context.classProperties = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_PROPERTY));
@@ -1,5 +1,7 @@
1
1
  export * from './customElementReact/index.js';
2
2
  export * from './customElement.js';
3
+ export * from './document.js';
4
+ export * from './external.js';
3
5
  export * from './extract.js';
4
6
  export * from './parse.js';
5
7
  export * from './read.js';
@@ -1,5 +1,7 @@
1
1
  export * from './customElementReact/index.js';
2
2
  export * from './customElement.js';
3
+ export * from './document.js';
4
+ export * from './external.js';
3
5
  export * from './extract.js';
4
6
  export * from './parse.js';
5
7
  export * from './read.js';
@@ -26,7 +26,7 @@ export const style = (options) => {
26
26
  }
27
27
  if (!context.stylePath)
28
28
  return;
29
- context.fileAST.program.body.unshift(t.importDeclaration([t.importDefaultSpecifier(t.identifier('AUTO_IMPORT_STYLE'))], t.stringLiteral(context.stylePath + '?inline')));
29
+ context.fileAST.program.body.unshift(t.importDeclaration([t.importDefaultSpecifier(t.identifier('AUTO_IMPORT_STYLE'))], t.stringLiteral(context.stylePath)));
30
30
  context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.identifier('AUTO_IMPORT_STYLE'), undefined, null, undefined, true));
31
31
  };
32
32
  return {
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ import { File, Node } from '@babel/types';
2
+ export declare const getTypeReference: (file: File, node: Node) => string | undefined;
@@ -0,0 +1,33 @@
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,10 +1,11 @@
1
1
  export * from './__dirname.js';
2
- export * from './get-initializer.js';
3
- export * from './get-tags.js';
4
- export * from './get-type.js';
5
- export * from './has-decorator.js';
6
- export * from './is-directory-empty.js';
7
- export * from './print-type.js';
2
+ export * from './getInitializer.js';
3
+ export * from './getType.js';
4
+ export * from './getTypeReference.js';
5
+ export * from './hasDecorator.js';
6
+ export * from './isDirectoryEmpty.js';
7
+ export * from './printType.js';
8
8
  export * from './print.js';
9
- export * from './render-template.js';
9
+ export * from './renderTemplate.js';
10
+ export * from './tags.js';
10
11
  export * from './visitor.js';
@@ -1,10 +1,11 @@
1
1
  export * from './__dirname.js';
2
- export * from './get-initializer.js';
3
- export * from './get-tags.js';
4
- export * from './get-type.js';
5
- export * from './has-decorator.js';
6
- export * from './is-directory-empty.js';
7
- export * from './print-type.js';
2
+ export * from './getInitializer.js';
3
+ export * from './getType.js';
4
+ export * from './getTypeReference.js';
5
+ export * from './hasDecorator.js';
6
+ export * from './isDirectoryEmpty.js';
7
+ export * from './printType.js';
8
8
  export * from './print.js';
9
- export * from './render-template.js';
9
+ export * from './renderTemplate.js';
10
+ export * from './tags.js';
10
11
  export * from './visitor.js';
File without changes
@@ -0,0 +1,13 @@
1
+ import { Node } from '@babel/types';
2
+ export interface Tag {
3
+ key?: string;
4
+ value?: string;
5
+ }
6
+ export interface TagParsed {
7
+ name?: string;
8
+ description?: string;
9
+ }
10
+ export declare const getTag: (node: Node, key?: string | undefined) => Tag | undefined;
11
+ export declare const getTags: (node: Node, filter?: string | undefined) => Array<Tag>;
12
+ export declare const hasTag: (node: Node, name: string) => Boolean;
13
+ export declare const parseTag: (tag: Tag, spliter?: string) => TagParsed;
@@ -0,0 +1,53 @@
1
+ export const getTag = (node, key) => {
2
+ return getTags(node, key).pop();
3
+ };
4
+ export const getTags = (node, filter) => {
5
+ var _a;
6
+ let tags = (_a = node['tags']) !== null && _a !== void 0 ? _a : [];
7
+ if (!node['tags']) {
8
+ const lines = [];
9
+ const comments = (node.leadingComments || [])
10
+ .slice(-1)
11
+ .map((comment) => comment.value)
12
+ .join('\r\n')
13
+ .split('\r\n');
14
+ for (const comment of comments) {
15
+ let line = comment.trimStart();
16
+ if (line.startsWith('*'))
17
+ line = line.slice(1);
18
+ if (!line)
19
+ continue;
20
+ const isTag = line.trim().startsWith('@');
21
+ if (isTag || !lines.length)
22
+ lines.push(line);
23
+ else
24
+ lines[lines.length - 1] += line;
25
+ }
26
+ for (const line of lines) {
27
+ let value = line.trim();
28
+ if (!value.startsWith('@')) {
29
+ tags.push({ value });
30
+ continue;
31
+ }
32
+ const sections = value.split(' ');
33
+ const key = sections[0].slice(1);
34
+ value = sections.slice(1).join(' ').trim();
35
+ tags.push({ key, value });
36
+ }
37
+ node['tags'] = tags;
38
+ }
39
+ return tags.filter((tag) => !filter || filter === tag.key);
40
+ };
41
+ export const hasTag = (node, name) => {
42
+ return getTags(node).some((tag) => tag.key === name);
43
+ };
44
+ export const parseTag = (tag, spliter = '-') => {
45
+ var _a, _b;
46
+ const sections = ((_a = tag.value) === null || _a === void 0 ? void 0 : _a.split(spliter)) || [];
47
+ const name = (_b = sections[0]) === null || _b === void 0 ? void 0 : _b.trim();
48
+ const description = sections.slice(1).join(spliter).trim();
49
+ return {
50
+ name,
51
+ description
52
+ };
53
+ };
@@ -1,7 +1,6 @@
1
1
  export declare const PACKAGE_NAME = "@htmlplus/element";
2
2
  export declare const API_HOST = "$host$";
3
3
  export declare const API_READY = "$ready$";
4
- export declare const API_SETUP = "$setup$";
5
4
  export declare const DECORATOR_ELEMENT = "Element";
6
5
  export declare const DECORATOR_EVENT = "Event";
7
6
  export declare const DECORATOR_PROPERTY = "Property";
@@ -2,7 +2,6 @@ export const PACKAGE_NAME = '@htmlplus/element';
2
2
  // apis
3
3
  export const API_HOST = '$host$';
4
4
  export const API_READY = '$ready$';
5
- export const API_SETUP = '$setup$';
6
5
  // decorators
7
6
  export const DECORATOR_ELEMENT = 'Element';
8
7
  export const DECORATOR_EVENT = 'Event';
package/package.json CHANGED
@@ -1,22 +1,12 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "0.3.3",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "author": "Masood Abdolian <m.abdolian@gmail.com>",
6
6
  "description": "Compiler of HTMLPlus",
7
7
  "type": "module",
8
- "main": "./client/index.js",
9
- "types": "./client/index.d.ts",
10
- "scripts": {
11
- "prebuild": "npm run clean",
12
- "build": "tsc",
13
- "build:watch": "tsc -w",
14
- "postbuild": "node scripts/build.post.js",
15
- "clean": "rimraf dist",
16
- "format": "prettier --write .",
17
- "dev:start": "node src/dev/scripts/start.js",
18
- "dev:build": "node src/dev/scripts/build.js"
19
- },
8
+ "main": "client/index.js",
9
+ "types": "client/index.d.ts",
20
10
  "files": [
21
11
  "client",
22
12
  "compiler",
@@ -26,6 +16,9 @@
26
16
  "package.json",
27
17
  "README.md"
28
18
  ],
19
+ "publishConfig": {
20
+ "directory": "dist"
21
+ },
29
22
  "engines": {
30
23
  "node": ">= 12.7.0"
31
24
  },
@@ -46,17 +39,21 @@
46
39
  "@types/node": "^16.11.11",
47
40
  "change-case": "^4.1.2",
48
41
  "fast-glob": "^3.2.11",
42
+ "fs-extra": "^10.1.0",
49
43
  "handlebars": "^4.7.7",
44
+ "listr2": "^4.0.5",
50
45
  "log-update": "^5.0.0",
51
- "ts-node": "^10.4.0",
46
+ "ora": "^6.1.0",
52
47
  "typescript": "^4.5.2",
53
- "uhtml": "^2.7.6"
48
+ "uhtml": "^3.0.1"
54
49
  },
55
50
  "devDependencies": {
56
51
  "@trivago/prettier-plugin-sort-imports": "^3.1.1",
57
- "cpy": "^9.0.0",
52
+ "cpy": "^9.0.1",
53
+ "nodemon": "^2.0.16",
58
54
  "prettier": "^2.5.0",
59
55
  "rimraf": "^3.0.2",
56
+ "ts-node": "^10.7.0",
60
57
  "vite": "^2.7.10"
61
58
  }
62
- }
59
+ }
@@ -4,7 +4,13 @@ export interface Context {
4
4
  dependenciesUnresolved?: Array<string>;
5
5
  isInvalid?: boolean;
6
6
  script?: string;
7
+ outputs?: Array<{
8
+ name: string;
9
+ options?: any;
10
+ output?: any;
11
+ }>;
7
12
  componentClassName?: string;
13
+ componentClassNamePrune?: string;
8
14
  componentInterfaceName?: string;
9
15
  componentKey?: string;
10
16
  componentTag?: string;
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './context.js';
2
2
  export * from './global.js';
3
3
  export * from './plugin.js';
4
- export * from './plus-element.js';
4
+ export * from './plusElement.js';
package/types/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './context.js';
2
2
  export * from './global.js';
3
3
  export * from './plugin.js';
4
- export * from './plus-element.js';
4
+ export * from './plusElement.js';
package/types/plugin.d.ts CHANGED
@@ -3,7 +3,8 @@ import { Global } from './global';
3
3
  export declare type Return<T> = void | T | Promise<T>;
4
4
  export declare type Plugin = {
5
5
  name: string;
6
- start?: (global: Global) => Return<Global>;
7
- next?: (context: Context, global: Global) => Return<Context>;
8
- finish?: (global: Global) => Return<Global>;
6
+ options?: any;
7
+ start?: (global: Global) => Return<void>;
8
+ next?: (context: Context, global: Global) => Return<any>;
9
+ finish?: (global: Global) => Return<void>;
9
10
  };
File without changes
File without changes
@@ -1,2 +0,0 @@
1
- import { PlusElement } from '../../types/index.js';
2
- export declare const isReady: (target: PlusElement) => boolean;
@@ -1,4 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- export const isReady = (target) => {
3
- return target[CONSTANTS.API_READY];
4
- };