@htmlplus/element 0.4.8 → 0.5.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 (49) hide show
  1. package/client/decorators/attributes.js +2 -3
  2. package/client/decorators/element.js +15 -18
  3. package/client/decorators/property.js +10 -20
  4. package/client/decorators/state.js +5 -9
  5. package/client/decorators/watch.d.ts +2 -0
  6. package/client/decorators/watch.js +10 -13
  7. package/client/helpers/query.js +3 -3
  8. package/client/helpers/queryAll.js +3 -3
  9. package/client/helpers/slots.js +10 -12
  10. package/client/utils/appendToMethod.d.ts +1 -1
  11. package/client/utils/appendToMethod.js +3 -3
  12. package/client/utils/call.d.ts +1 -1
  13. package/client/utils/call.js +2 -2
  14. package/client/utils/index.d.ts +1 -0
  15. package/client/utils/index.js +1 -0
  16. package/client/utils/request.d.ts +8 -3
  17. package/client/utils/request.js +51 -25
  18. package/client/utils/shadowRoot.d.ts +2 -0
  19. package/client/utils/shadowRoot.js +5 -0
  20. package/client/utils/task.d.ts +4 -4
  21. package/client/utils/task.js +5 -8
  22. package/compiler/compiler.js +21 -20
  23. package/compiler/plugins/assets.d.ts +1 -0
  24. package/compiler/plugins/assets.js +9 -2
  25. package/compiler/plugins/copy.d.ts +3 -4
  26. package/compiler/plugins/copy.js +6 -3
  27. package/compiler/plugins/customElement.js +10 -2
  28. package/compiler/plugins/customElementReact/customElementReact.d.ts +9 -3
  29. package/compiler/plugins/customElementReact/customElementReact.js +9 -42
  30. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +10 -7
  31. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +3 -3
  32. package/compiler/plugins/document.d.ts +2 -1
  33. package/compiler/plugins/document.js +9 -32
  34. package/compiler/plugins/extract.js +2 -4
  35. package/compiler/plugins/index.d.ts +1 -0
  36. package/compiler/plugins/index.js +1 -0
  37. package/compiler/plugins/parse.d.ts +3 -1
  38. package/compiler/plugins/parse.js +8 -7
  39. package/compiler/plugins/readme.d.ts +8 -0
  40. package/compiler/plugins/readme.js +23 -0
  41. package/compiler/plugins/style.d.ts +2 -2
  42. package/compiler/plugins/style.js +8 -5
  43. package/compiler/plugins/webTypes.d.ts +3 -2
  44. package/compiler/plugins/webTypes.js +15 -15
  45. package/compiler/utils/tags.js +21 -32
  46. package/constants/index.d.ts +11 -6
  47. package/constants/index.js +11 -7
  48. package/package.json +1 -1
  49. package/types/context.d.ts +13 -15
@@ -3,6 +3,7 @@ import { pascalCase } from 'change-case';
3
3
  import * as CONSTANTS from '../../constants/index.js';
4
4
  import { addDependency, print, visitor } from '../utils/index.js';
5
5
  const defaults = {
6
+ // prefix: undefined,
6
7
  typings: true
7
8
  };
8
9
  // TODO: support {variable && jsxElement}
@@ -96,6 +97,7 @@ export const customElement = (options) => {
96
97
  return;
97
98
  const node = t.classProperty(t.identifier(CONSTANTS.STATIC_MEMBERS), t.objectExpression([
98
99
  ...context.classProperties.map((property) => {
100
+ var _a, _b, _c, _d, _e, _f;
99
101
  const properties = [];
100
102
  if (property.value) {
101
103
  properties.push(t.objectProperty(t.identifier(CONSTANTS.STATIC_MEMBERS_INITIALIZER), property.value));
@@ -114,6 +116,12 @@ export const customElement = (options) => {
114
116
  if (type) {
115
117
  properties.push(t.objectProperty(t.identifier(CONSTANTS.STATIC_MEMBERS_TYPE), type));
116
118
  }
119
+ // TODO
120
+ // prettier-ignore
121
+ (_f = (_e = (_d = (_c = (_b = (_a = property === null || property === void 0 ? void 0 : property.decorators) === null || _a === void 0 ? void 0 : _a.find((decorator) => {
122
+ var _a, _b;
123
+ return ((_b = (_a = decorator.expression) === null || _a === void 0 ? void 0 : _a['callee']) === null || _b === void 0 ? void 0 : _b.name) == CONSTANTS.DECORATOR_PROPERTY;
124
+ })) === null || _b === void 0 ? void 0 : _b.expression) === null || _c === void 0 ? void 0 : _c['arguments']) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.properties) === null || _f === void 0 ? void 0 : _f.forEach((property) => properties.push(property));
117
125
  return t.objectProperty(t.identifier(property.key['name']), t.objectExpression(properties));
118
126
  }),
119
127
  ...context.classMethods.map((method) => t.objectProperty(t.identifier(method.key['name']), t.objectExpression([
@@ -131,7 +139,7 @@ export const customElement = (options) => {
131
139
  const { body } = path.node;
132
140
  body.push(t.exportNamedDeclaration(t.tsInterfaceDeclaration(
133
141
  // TODO
134
- t.identifier(context.componentClassName + 'JSX'), null, [], t.tsInterfaceBody([
142
+ t.identifier(context.className + 'JSX'), null, [], t.tsInterfaceBody([
135
143
  ...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
136
144
  optional: property.optional,
137
145
  leadingComments: t.cloneNode(property, true).leadingComments
@@ -171,7 +179,7 @@ export const customElement = (options) => {
171
179
  t.tSModuleDeclaration(t.identifier('JSX'), t.tSModuleBlock([
172
180
  t.tSInterfaceDeclaration(t.identifier('IntrinsicElements'), undefined, undefined, t.tSInterfaceBody([
173
181
  t.tSPropertySignature(t.stringLiteral(context.componentTag), t.tSTypeAnnotation(t.tSIntersectionType([
174
- t.tSTypeReference(t.identifier(context.componentClassName + 'JSX')),
182
+ t.tSTypeReference(t.identifier(context.className + 'JSX')),
175
183
  t.tSTypeLiteral([
176
184
  t.tSIndexSignature([
177
185
  Object.assign({}, t.identifier('key'), {
@@ -1,10 +1,16 @@
1
- import { Global } from '../../../types';
1
+ import { Context, Global } from '../../../types';
2
2
  export interface CustomElementReactOptions {
3
3
  compact?: boolean;
4
4
  destination: string;
5
5
  eventName?: (eventName: string) => string;
6
- importerComponent?: (context: any) => string;
7
- importerComponentType?: (context: any) => string;
6
+ importerComponent: (context: Context) => {
7
+ source: string;
8
+ };
9
+ importerComponentType: (context: Context) => {
10
+ source: string;
11
+ imported: string;
12
+ local: string;
13
+ };
8
14
  }
9
15
  export declare const customElementReact: (options: CustomElementReactOptions) => {
10
16
  name: string;
@@ -1,18 +1,6 @@
1
1
  import { pascalCase } from 'change-case';
2
2
  import { __dirname, isDirectoryEmpty, renderTemplate } from '../../utils/index.js';
3
- const defaults = {
4
- compact: false,
5
- destination: '',
6
- eventName(eventName) {
7
- return eventName;
8
- },
9
- importerComponent(context) {
10
- return `YOUR_CORE_PACKAGE_NAME#${context.componentClassName}`;
11
- },
12
- importerComponentType(context) {
13
- return `YOUR_CORE_PACKAGE_NAME#JSX.${context.componentClassName}`;
14
- }
15
- };
3
+ const defaults = {};
16
4
  export const customElementReact = (options) => {
17
5
  const name = 'customElementReact';
18
6
  options = Object.assign({}, defaults, options);
@@ -25,28 +13,19 @@ export const customElementReact = (options) => {
25
13
  const config = { cwd: __dirname(import.meta.url) };
26
14
  const isEmpty = isDirectoryEmpty(options.destination);
27
15
  const skip = [];
28
- const getKey = (component) => component.componentClassName;
16
+ const getKey = (component) => component.className;
29
17
  for (const key in globalNew.contexts) {
30
18
  const context = globalNew.contexts[key];
31
- const parse = (input) => {
32
- const [source, key] = input.split('#');
33
- const [root, ...sub] = key.split('.');
34
- const variable = ['Type', ...sub].join('.');
35
- return {
36
- source,
37
- variable,
38
- root
39
- };
40
- };
41
19
  const classEvents = context.classEvents.map((classEvent) => {
20
+ var _a, _b;
42
21
  const from = 'on' + pascalCase(classEvent.key.name);
43
- const to = options.eventName(from);
22
+ const to = (_b = (_a = options.eventName) === null || _a === void 0 ? void 0 : _a.call(options, from)) !== null && _b !== void 0 ? _b : from;
44
23
  return Object.assign(Object.assign({}, classEvent), { from,
45
24
  to });
46
25
  });
47
26
  const fileName = context.fileName;
48
- const importerComponent = parse(options.importerComponent(context));
49
- const importerComponentType = parse(options.importerComponentType(context));
27
+ const importerComponent = options.importerComponent(context);
28
+ const importerComponentType = options.importerComponentType(context);
50
29
  const state = Object.assign(Object.assign({}, context), { classEvents,
51
30
  fileName,
52
31
  importerComponent,
@@ -77,26 +56,14 @@ export const customElementReact = (options) => {
77
56
  .reverse()
78
57
  .map((component, index) => {
79
58
  const componentClassNameInCategory = getKey(component).replace(group.key, '');
80
- const parse = (input) => {
81
- const [source, key] = input.split('#');
82
- const [root, ...sub] = key.split('.');
83
- const local = root + (index + 1);
84
- const variable = [local, ...sub].join('.');
85
- return {
86
- source,
87
- variable,
88
- root,
89
- local
90
- };
91
- };
92
- const importerComponent = parse(options.importerComponent(component));
93
- const importerComponentType = parse(options.importerComponentType(component));
59
+ const importerComponent = options.importerComponent(component);
60
+ const importerComponentType = options.importerComponentType(component);
94
61
  return Object.assign(Object.assign({}, component), { componentClassNameInCategory,
95
62
  importerComponent,
96
63
  importerComponentType });
97
64
  })
98
65
  // TODO: experimental
99
- .sort((a, b) => (b.componentClassName < a.componentClassName ? 0 : -1));
66
+ .sort((a, b) => (getKey(b) < getKey(a) ? 0 : -1));
100
67
  return {
101
68
  all,
102
69
  filterd: all.slice(1),
@@ -3,13 +3,16 @@
3
3
  **************************************************/
4
4
 
5
5
  {{#each all}}
6
- import { {{componentClassNamePrune}} } from './{{fileName}}';
6
+ import { {{className}} } from './{{fileName}}';
7
7
  {{/each}}
8
8
 
9
- const All = Object.assign({{root.componentClassNamePrune}}, {
10
- {{#each filterd}}
11
- {{componentClassNameInCategory}}: {{componentClassNamePrune}},
12
- {{/each}}
13
- });
9
+ const All = Object.assign(
10
+ {{root.className}},
11
+ {
12
+ {{#each filterd}}
13
+ {{componentClassNameInCategory}}: {{className}},
14
+ {{/each}}
15
+ }
16
+ );
14
17
 
15
- export { All as {{root.componentClassNamePrune}} }
18
+ export { All as {{root.className}} }
@@ -5,17 +5,17 @@
5
5
  import { proxy } from '../proxy';
6
6
 
7
7
  import '{{importerComponent.source}}';
8
- import type { {{importerComponentType.root}} as Type } from '{{importerComponentType.source}}';
8
+ import type { {{importerComponentType.imported}} as {{importerComponentType.local}} } from '{{importerComponentType.source}}';
9
9
 
10
10
  type Rename<T, R extends { [K in keyof R]: K extends keyof T ? PropertyKey : "Error: key not in T" }> = { [P in keyof T as P extends keyof R ? R[P] : P]: T[P] }
11
11
 
12
- type Renamed = Rename<{{importerComponentType.variable}}, {
12
+ type Renamed = Rename<{{importerComponentType.local}}, {
13
13
  {{#each classEvents}}
14
14
  {{from}}: '{{to}}',
15
15
  {{/each}}
16
16
  }>
17
17
 
18
- export const {{componentClassNamePrune}} = proxy<{{componentInterfaceName}}, Renamed>(
18
+ export const {{className}} = proxy<{{componentInterfaceName}}, Renamed>(
19
19
  '{{componentTag}}',
20
20
  [{{#each classProperties}}'{{key.name}}', {{/each}}],
21
21
  [{{#each classEvents}}'{{key.name}}', {{/each}}],
@@ -1,6 +1,7 @@
1
- import { Global } from '../../types';
1
+ import { Context, Global } from '../../types';
2
2
  export interface DocumentOptions {
3
3
  destination: string;
4
+ transformer?: (context: Context, element: any) => any;
4
5
  }
5
6
  export declare const document: (options: DocumentOptions) => {
6
7
  name: string;
@@ -8,12 +8,13 @@ export const document = (options) => {
8
8
  const name = 'document';
9
9
  options = Object.assign({}, defaults, options);
10
10
  const finish = (global) => {
11
- var _a;
11
+ var _a, _b, _c;
12
12
  const json = {
13
13
  components: []
14
14
  };
15
15
  for (const context of global.contexts) {
16
16
  const deprecated = hasTag(context.class, 'deprecated');
17
+ const description = (_a = getTags(context.class).find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
17
18
  const events = context.classEvents.map((event) => {
18
19
  var _a, _b, _c;
19
20
  const cancelable = (() => {
@@ -58,7 +59,7 @@ export const document = (options) => {
58
59
  };
59
60
  });
60
61
  const experimental = hasTag(context.class, 'experimental');
61
- const group = (_a = getTag(context.class, 'group')) === null || _a === void 0 ? void 0 : _a.value;
62
+ const group = (_b = getTag(context.class, 'group')) === null || _b === void 0 ? void 0 : _b.value;
62
63
  const lastModified = glob
63
64
  .sync(path.join(context.directoryPath, '**/*.*'))
64
65
  .map((file) => fs.statSync(file).mtime)
@@ -170,26 +171,6 @@ export const document = (options) => {
170
171
  typeReference
171
172
  };
172
173
  });
173
- const readme = (() => {
174
- try {
175
- const source = path.join(context.directoryPath, `${context.fileName}.md`);
176
- return fs.readFileSync(source, 'utf8');
177
- }
178
- catch (_a) { }
179
- })();
180
- const readmeDescription = (() => {
181
- const content = readme || '';
182
- if (!content.startsWith('# '))
183
- return '';
184
- const sections = content.split('\n');
185
- for (let i = 1; i < sections.length; i++) {
186
- const section = sections[i].trim();
187
- if (!section)
188
- continue;
189
- return section;
190
- }
191
- return '';
192
- })();
193
174
  const slots = getTags(context.class, 'slot').map((tag) => parseTag(tag));
194
175
  // TODO
195
176
  const styles = (() => {
@@ -214,31 +195,27 @@ export const document = (options) => {
214
195
  };
215
196
  });
216
197
  })();
217
- const tag = context.componentTag;
218
198
  const tags = getTags(context.class);
219
199
  const title = capitalCase(context.componentKey);
220
- json.components.push({
221
- // TODO
222
- // main
223
- // development
224
- // source
200
+ const component = {
225
201
  events,
226
202
  group,
227
203
  deprecated,
204
+ description,
228
205
  experimental,
229
206
  key: context.componentKey,
230
207
  lastModified,
231
208
  methods,
232
209
  parts,
233
210
  properties,
234
- readme,
235
- readmeDescription,
211
+ readmeContent: context.readmeContent,
236
212
  slots,
237
213
  styles,
238
- tag,
239
214
  tags,
240
215
  title
241
- });
216
+ };
217
+ const transformed = ((_c = options.transformer) === null || _c === void 0 ? void 0 : _c.call(options, context, component)) || component;
218
+ json.components.push(transformed);
242
219
  }
243
220
  json.components = json.components.sort((a, b) => (a.title > b.title ? 1 : -1));
244
221
  const dirname = path.dirname(options.destination);
@@ -56,11 +56,9 @@ export const extract = (options) => {
56
56
  context.fileExtension = path.extname(context.filePath);
57
57
  context.fileName = path.basename(context.filePath, context.fileExtension);
58
58
  context.className = (_b = (_a = context.class) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.name;
59
+ context.componentKey = paramCase(context.className);
59
60
  // TODO
60
- context.componentClassName = pascalCase(context.componentTag);
61
- context.componentClassNamePrune = pascalCase(context.componentTag.split('-').slice(1).join('-'));
62
- context.componentInterfaceName = `HTML${context.componentClassName}Element`;
63
- context.componentKey = paramCase(context.componentClassNamePrune);
61
+ context.componentInterfaceName = `HTML${pascalCase(context.componentTag)}Element`;
64
62
  context.classEvents = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_EVENT));
65
63
  context.classMethods = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_METHOD));
66
64
  context.classProperties = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_PROPERTY));
@@ -6,6 +6,7 @@ export * from './document.js';
6
6
  export * from './extract.js';
7
7
  export * from './parse.js';
8
8
  export * from './read.js';
9
+ export * from './readme.js';
9
10
  export * from './style.js';
10
11
  export * from './validate.js';
11
12
  export * from './webTypes.js';
@@ -6,6 +6,7 @@ export * from './document.js';
6
6
  export * from './extract.js';
7
7
  export * from './parse.js';
8
8
  export * from './read.js';
9
+ export * from './readme.js';
9
10
  export * from './style.js';
10
11
  export * from './validate.js';
11
12
  export * from './webTypes.js';
@@ -1,5 +1,7 @@
1
+ import { ParserOptions } from '@babel/parser';
1
2
  import { Context } from '../../types';
2
- export declare const parse: () => {
3
+ export declare type ParseOptions = ParserOptions;
4
+ export declare const parse: (options?: ParseOptions) => {
3
5
  name: string;
4
6
  next: (context: Context) => void;
5
7
  };
@@ -1,13 +1,14 @@
1
1
  import { parse as parser } from '@babel/parser';
2
- export const parse = () => {
2
+ const defaults = {
3
+ allowImportExportEverywhere: true,
4
+ plugins: ['jsx', 'typescript', 'decorators-legacy']
5
+ };
6
+ export const parse = (options) => {
3
7
  const name = 'parse';
8
+ options = Object.assign({}, defaults, options);
4
9
  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
- });
10
+ var _a;
11
+ context.fileAST = (_a = context.fileAST) !== null && _a !== void 0 ? _a : parser(context.fileContent, options);
11
12
  };
12
13
  return { name, next };
13
14
  };
@@ -0,0 +1,8 @@
1
+ import { Context, Global } from '../../types';
2
+ export declare type ReadmeOptions = {
3
+ source?: (context: Context) => string;
4
+ };
5
+ export declare const readme: (options: ReadmeOptions) => {
6
+ name: string;
7
+ finish: (global: Global) => void;
8
+ };
@@ -0,0 +1,23 @@
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ const defaults = {
4
+ source(context) {
5
+ return path.join(context.directoryPath, `${context.fileName}.md`);
6
+ }
7
+ };
8
+ export const readme = (options) => {
9
+ const name = 'readme';
10
+ options = Object.assign({}, defaults, options);
11
+ const finish = (global) => {
12
+ var _a;
13
+ for (const context of global.contexts) {
14
+ context.readmePath = (_a = options.source) === null || _a === void 0 ? void 0 : _a.call(options, context);
15
+ if (!context.readmePath)
16
+ continue;
17
+ if (!fs.existsSync(context.readmePath))
18
+ continue;
19
+ context.readmeContent = fs.readFileSync(context.readmePath, 'utf8');
20
+ }
21
+ };
22
+ return { name, finish };
23
+ };
@@ -1,8 +1,8 @@
1
1
  import { Context } from '../../types';
2
2
  export declare type StyleOptions = {
3
- references?: (context: Context) => string | string[];
3
+ source?: (context: Context) => string | string[];
4
4
  };
5
- export declare const style: (options: StyleOptions) => {
5
+ export declare const style: (options?: StyleOptions) => {
6
6
  name: string;
7
7
  next: (context: Context) => void;
8
8
  };
@@ -4,7 +4,7 @@ import path from 'path';
4
4
  import * as CONSTANTS from '../../constants/index.js';
5
5
  import { addDependency } from '../utils/index.js';
6
6
  const defaults = {
7
- references(context) {
7
+ source(context) {
8
8
  return [
9
9
  path.join(context.directoryPath, `${context.fileName}.css`),
10
10
  path.join(context.directoryPath, `${context.fileName}.less`),
@@ -18,11 +18,14 @@ export const style = (options) => {
18
18
  const name = 'style';
19
19
  options = Object.assign({}, defaults, options);
20
20
  const next = (context) => {
21
- const references = [options.references(context)].flat();
22
- for (const reference of references) {
23
- if (!fs.existsSync(reference))
21
+ var _a;
22
+ const sources = [(_a = options === null || options === void 0 ? void 0 : options.source) === null || _a === void 0 ? void 0 : _a.call(options, context)].flat();
23
+ for (const source of sources) {
24
+ if (!source)
24
25
  continue;
25
- context.stylePath = reference;
26
+ if (!fs.existsSync(source))
27
+ continue;
28
+ context.stylePath = source;
26
29
  break;
27
30
  }
28
31
  if (!context.stylePath)
@@ -1,9 +1,10 @@
1
- import { Global } from '../../types';
1
+ import { Context, Global } from '../../types';
2
2
  export interface WebTypesOptions {
3
3
  destination: string;
4
4
  packageName: string;
5
5
  packageVersion: string;
6
- reference?: (componentTag: string) => string;
6
+ reference?: (context: Context) => string;
7
+ transformer?: (context: Context, component: any) => any;
7
8
  }
8
9
  export declare const webTypes: (options: WebTypesOptions) => {
9
10
  name: string;
@@ -7,7 +7,7 @@ export const webTypes = (options) => {
7
7
  const name = 'webTypes';
8
8
  options = Object.assign({}, defaults, options);
9
9
  const finish = (global) => {
10
- var _a, _b, _c, _d, _e;
10
+ var _a, _b, _c, _d, _e, _f, _g;
11
11
  const json = {
12
12
  '$schema': 'http://json.schemastore.org/web-types',
13
13
  'name': options.packageName,
@@ -24,7 +24,7 @@ export const webTypes = (options) => {
24
24
  }
25
25
  }
26
26
  };
27
- const extract = (member) => {
27
+ const common = (member) => {
28
28
  var _a;
29
29
  return ({
30
30
  name: member.key['name'],
@@ -36,7 +36,7 @@ export const webTypes = (options) => {
36
36
  for (const context of global.contexts) {
37
37
  const attributes = (_a = context.classProperties) === null || _a === void 0 ? void 0 : _a.map((property) => {
38
38
  var _a;
39
- return Object.assign({}, extract(property), {
39
+ return Object.assign(common(property), {
40
40
  name: paramCase(property.key['name']),
41
41
  value: {
42
42
  // kind: TODO
@@ -60,31 +60,29 @@ export const webTypes = (options) => {
60
60
  default: getInitializer(property.value)
61
61
  });
62
62
  });
63
- const events = (_b = context.classEvents) === null || _b === void 0 ? void 0 : _b.map((event) => Object.assign({}, extract(event), {
63
+ const description = (_b = getTags(context.class).find((tag) => !tag.key)) === null || _b === void 0 ? void 0 : _b.value;
64
+ const events = (_c = context.classEvents) === null || _c === void 0 ? void 0 : _c.map((event) => Object.assign(common(event), {
64
65
  name: paramCase(event.key['name']) // TODO
65
66
  // 'value': TODO
66
67
  }));
67
- const methods = (_c = context.classMethods) === null || _c === void 0 ? void 0 : _c.map((method) => Object.assign({}, extract(method), {
68
+ const methods = (_d = context.classMethods) === null || _d === void 0 ? void 0 : _d.map((method) => Object.assign(common(method), {
68
69
  // 'value': TODO
69
70
  }));
70
- const properties = (_d = context.classProperties) === null || _d === void 0 ? void 0 : _d.map((property) => Object.assign({}, extract(property), {
71
+ const properties = (_e = context.classProperties) === null || _e === void 0 ? void 0 : _e.map((property) => Object.assign(common(property), {
71
72
  // 'value': TODO
72
73
  default: getInitializer(property.value)
73
74
  }));
74
75
  const slots = getTags(context.class, 'slot').map((tag) => {
75
76
  const { description, name } = parseTag(tag);
76
77
  return {
77
- 'name': name,
78
- 'description': description,
79
- 'doc-url': undefined,
80
- 'deprecated': false,
81
- 'experimental': false
78
+ name,
79
+ description
82
80
  };
83
81
  });
84
- json.contributions.html.elements.push({
82
+ const component = {
85
83
  'name': context.componentTag,
86
- 'description': 'TODO',
87
- 'doc-url': (_e = options.reference) === null || _e === void 0 ? void 0 : _e.call(options, context.componentTag),
84
+ 'description': description,
85
+ 'doc-url': (_f = options.reference) === null || _f === void 0 ? void 0 : _f.call(options, context),
88
86
  'deprecated': hasTag(context.class, 'deprecated'),
89
87
  'experimental': hasTag(context.class, 'experimental'),
90
88
  'js': {
@@ -93,7 +91,9 @@ export const webTypes = (options) => {
93
91
  },
94
92
  attributes,
95
93
  slots
96
- });
94
+ };
95
+ const transformed = ((_g = options.transformer) === null || _g === void 0 ? void 0 : _g.call(options, context, component)) || component;
96
+ json.contributions.html.elements.push(transformed);
97
97
  }
98
98
  const dirname = path.dirname(options.destination);
99
99
  fs.ensureDirSync(dirname);
@@ -2,39 +2,28 @@ export const getTag = (node, key) => {
2
2
  return getTags(node, key).pop();
3
3
  };
4
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;
5
+ var _a, _b, _c, _d;
6
+ const tags = [];
7
+ const lines = (_d = (_c = (_b = (_a = node.leadingComments) === null || _a === void 0 ? void 0 : _a.map((comment) => {
8
+ const { type, value } = comment;
9
+ if (type == 'CommentLine')
10
+ return value;
11
+ return value.replace(/\r\n/g, '\n').split('\n');
12
+ })) === null || _b === void 0 ? void 0 : _b.flat()) === null || _c === void 0 ? void 0 : _c.filter((line) => line.trim().replace(/\*/g, ''))) === null || _d === void 0 ? void 0 : _d.map((line) => line.replace(/^( +)?(\*+)?( +)?/, ''));
13
+ for (const line of lines || []) {
14
+ const has = !!tags.length;
15
+ const isTag = line.startsWith('@');
16
+ if (isTag) {
17
+ const [key, ...values] = line.split(' ');
18
+ tags.push({
19
+ key: key.slice(1).trim(),
20
+ value: values.join(' ').trimStart()
21
+ });
22
+ continue;
25
23
  }
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;
24
+ if (!has)
25
+ tags.push({ key: '', value: '' });
26
+ tags[tags.length - 1].value += line;
38
27
  }
39
28
  return tags.filter((tag) => !filter || filter === tag.key);
40
29
  };
@@ -1,7 +1,12 @@
1
1
  export declare const PACKAGE_NAME = "@htmlplus/element";
2
2
  export declare const API_HOST: unique symbol;
3
3
  export declare const API_INSTANCE: unique symbol;
4
- export declare const API_STATUS: unique symbol;
4
+ export declare const API_IS_CONNECTED: unique symbol;
5
+ export declare const API_IS_DISABLED_ATTRIBUTE_CHANGED_CALLBACK: unique symbol;
6
+ export declare const API_IS_LOADED: unique symbol;
7
+ export declare const API_ATTRIBUTES_SYNCER: unique symbol;
8
+ export declare const API_REQUEST: unique symbol;
9
+ export declare const API_STACKS: unique symbol;
5
10
  export declare const DECORATOR_ELEMENT = "Element";
6
11
  export declare const DECORATOR_EVENT = "Event";
7
12
  export declare const DECORATOR_PROPERTY = "Property";
@@ -18,11 +23,11 @@ export declare const STATIC_MEMBERS = "members";
18
23
  export declare const STATIC_MEMBERS_INITIALIZER = "default";
19
24
  export declare const STATIC_MEMBERS_TYPE = "type";
20
25
  export declare const STATIC_STYLES = "styles";
21
- export declare const TYPE_BOOLEAN = "boolean";
22
- export declare const TYPE_DATE = "date";
23
- export declare const TYPE_FUNCTION = "function";
24
- export declare const TYPE_STRING = "string";
25
- export declare const TYPE_NUMBER = "number";
26
+ export declare const TYPE_BOOLEAN = "Boolean";
27
+ export declare const TYPE_DATE = "Date";
28
+ export declare const TYPE_FUNCTION = "Function";
29
+ export declare const TYPE_STRING = "String";
30
+ export declare const TYPE_NUMBER = "Number";
26
31
  export declare const UTILS_STYLE_MAP = "styles";
27
32
  export declare const VENDOR_UHTML = "@htmlplus/element/client/vendors/uhtml.js";
28
33
  export declare const AUTO_IMPORT_STYLE = "AUTO_IMPORT_STYLE";