@htmlplus/element 0.8.6 → 1.1.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 (184) hide show
  1. package/README.md +616 -534
  2. package/bundlers/rollup.d.ts +2 -2
  3. package/bundlers/rollup.js +5 -5
  4. package/bundlers/vite.d.ts +2 -2
  5. package/bundlers/vite.js +5 -5
  6. package/client/decorators/bind.d.ts +4 -0
  7. package/client/decorators/bind.js +4 -0
  8. package/client/decorators/direction.d.ts +5 -0
  9. package/client/decorators/direction.js +8 -0
  10. package/client/decorators/element.d.ts +5 -0
  11. package/client/decorators/element.js +7 -2
  12. package/client/decorators/event.d.ts +21 -7
  13. package/client/decorators/event.js +7 -2
  14. package/client/decorators/host.d.ts +4 -2
  15. package/client/decorators/host.js +5 -8
  16. package/client/decorators/index.d.ts +3 -0
  17. package/client/decorators/index.js +3 -0
  18. package/client/decorators/isRTL.d.ts +4 -0
  19. package/client/decorators/isRTL.js +7 -0
  20. package/client/decorators/listen.d.ts +38 -8
  21. package/client/decorators/listen.js +9 -12
  22. package/client/decorators/method.d.ts +4 -0
  23. package/client/decorators/method.js +4 -0
  24. package/client/decorators/property.d.ts +8 -1
  25. package/client/decorators/property.js +4 -0
  26. package/client/decorators/query.d.ts +9 -2
  27. package/client/decorators/query.js +10 -9
  28. package/client/decorators/queryAll.d.ts +12 -2
  29. package/client/decorators/queryAll.js +13 -9
  30. package/client/decorators/slots.d.ts +4 -0
  31. package/client/decorators/slots.js +7 -0
  32. package/client/decorators/state.d.ts +4 -0
  33. package/client/decorators/state.js +4 -0
  34. package/client/decorators/watch.d.ts +5 -4
  35. package/client/decorators/watch.js +5 -4
  36. package/client/index.d.ts +1 -3
  37. package/client/index.js +1 -3
  38. package/client/utils/classes.d.ts +3 -0
  39. package/client/utils/classes.js +11 -28
  40. package/client/utils/config.d.ts +25 -3
  41. package/client/utils/config.js +18 -10
  42. package/client/utils/direction.d.ts +5 -2
  43. package/client/utils/direction.js +5 -1
  44. package/client/utils/event.d.ts +6 -0
  45. package/client/utils/event.js +6 -0
  46. package/client/utils/host.d.ts +3 -0
  47. package/client/utils/host.js +3 -0
  48. package/client/utils/index.d.ts +4 -1
  49. package/client/utils/index.js +4 -1
  50. package/client/utils/isCSSColor.d.ts +5 -0
  51. package/client/utils/isCSSColor.js +9 -0
  52. package/client/utils/isRTL.d.ts +3 -0
  53. package/client/utils/isRTL.js +3 -0
  54. package/client/utils/isServer.d.ts +3 -0
  55. package/client/utils/isServer.js +3 -0
  56. package/client/utils/query.d.ts +5 -0
  57. package/client/utils/query.js +8 -0
  58. package/client/utils/queryAll.d.ts +5 -0
  59. package/client/utils/queryAll.js +8 -0
  60. package/client/utils/request.d.ts +1 -1
  61. package/client/utils/request.js +1 -1
  62. package/client/utils/slots.d.ts +3 -0
  63. package/client/utils/slots.js +6 -1
  64. package/client/utils/styles.d.ts +3 -0
  65. package/client/utils/styles.js +3 -0
  66. package/client/utils/toDecorator.d.ts +2 -0
  67. package/client/utils/toDecorator.js +10 -0
  68. package/client/utils/toUnit.d.ts +4 -1
  69. package/client/utils/toUnit.js +6 -3
  70. package/constants/index.d.ts +1 -0
  71. package/constants/index.js +2 -0
  72. package/package.json +11 -4
  73. package/transformer/index.d.ts +3 -0
  74. package/transformer/index.js +3 -0
  75. package/transformer/plugins/assets.d.ts +8 -0
  76. package/transformer/plugins/assets.js +29 -0
  77. package/{compiler → transformer}/plugins/copy.d.ts +2 -2
  78. package/{compiler → transformer}/plugins/customElement.d.ts +2 -2
  79. package/{compiler → transformer}/plugins/customElement.js +13 -12
  80. package/{compiler → transformer}/plugins/customElementReact/customElementReact.d.ts +4 -4
  81. package/{compiler → transformer}/plugins/customElementReact/customElementReact.js +18 -18
  82. package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +1 -1
  83. package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +3 -3
  84. package/transformer/plugins/customElementReact/templates/src/index.ts.hbs +1 -0
  85. package/transformer/plugins/document.d.ts +7 -0
  86. package/{compiler → transformer}/plugins/document.js +18 -18
  87. package/transformer/plugins/extract.d.ts +2 -0
  88. package/{compiler → transformer}/plugins/extract.js +1 -18
  89. package/transformer/plugins/parse.d.ts +6 -0
  90. package/{compiler → transformer}/plugins/parse.js +1 -1
  91. package/transformer/plugins/read.d.ts +8 -0
  92. package/transformer/plugins/read.js +20 -0
  93. package/transformer/plugins/readme.d.ts +6 -0
  94. package/{compiler → transformer}/plugins/readme.js +3 -2
  95. package/transformer/plugins/style.d.ts +6 -0
  96. package/{compiler → transformer}/plugins/style.js +4 -2
  97. package/transformer/plugins/validate.d.ts +2 -0
  98. package/transformer/plugins/validate.js +41 -0
  99. package/transformer/plugins/visualStudioCode.d.ts +8 -0
  100. package/{compiler → transformer}/plugins/visualStudioCode.js +10 -8
  101. package/transformer/plugins/webTypes.d.ts +10 -0
  102. package/{compiler → transformer}/plugins/webTypes.js +11 -7
  103. package/transformer/transformer.d.ts +6 -0
  104. package/{compiler/compiler.js → transformer/transformer.js} +17 -17
  105. package/transformer/transformer.types.d.ts +50 -0
  106. package/{compiler → transformer}/utils/printType.js +2 -2
  107. package/{compiler → transformer}/utils/renderTemplate.js +2 -0
  108. package/types/index.d.ts +2 -4
  109. package/types/index.js +1 -4
  110. package/bundlers/index.d.ts +0 -2
  111. package/bundlers/index.js +0 -2
  112. package/client/helpers/index.d.ts +0 -1
  113. package/client/helpers/index.js +0 -1
  114. package/client/services/index.d.ts +0 -1
  115. package/client/services/index.js +0 -1
  116. package/client/services/link.d.ts +0 -4
  117. package/client/services/link.js +0 -196
  118. package/client/utils/getNamespace.d.ts +0 -2
  119. package/client/utils/getNamespace.js +0 -4
  120. package/client/vendors/uhtml.d.ts +0 -29
  121. package/client/vendors/uhtml.js +0 -700
  122. package/compiler/compiler.d.ts +0 -6
  123. package/compiler/index.d.ts +0 -2
  124. package/compiler/index.js +0 -2
  125. package/compiler/plugins/assets.d.ts +0 -8
  126. package/compiler/plugins/assets.js +0 -33
  127. package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
  128. package/compiler/plugins/document.d.ts +0 -7
  129. package/compiler/plugins/extract.d.ts +0 -2
  130. package/compiler/plugins/parse.d.ts +0 -5
  131. package/compiler/plugins/read.d.ts +0 -8
  132. package/compiler/plugins/read.js +0 -13
  133. package/compiler/plugins/readme.d.ts +0 -6
  134. package/compiler/plugins/style.d.ts +0 -6
  135. package/compiler/plugins/validate.d.ts +0 -2
  136. package/compiler/plugins/validate.js +0 -37
  137. package/compiler/plugins/visualStudioCode.d.ts +0 -8
  138. package/compiler/plugins/webTypes.d.ts +0 -10
  139. package/types/context.d.ts +0 -31
  140. package/types/global.d.ts +0 -4
  141. package/types/global.js +0 -1
  142. package/types/plugin.d.ts +0 -10
  143. package/types/plugin.js +0 -1
  144. package/types/plusElement.d.ts +0 -2
  145. package/types/plusElement.js +0 -1
  146. /package/{compiler → transformer}/plugins/copy.js +0 -0
  147. /package/{compiler → transformer}/plugins/customElementReact/index.d.ts +0 -0
  148. /package/{compiler → transformer}/plugins/customElementReact/index.js +0 -0
  149. /package/{compiler → transformer}/plugins/customElementReact/templates/README.md.hbs +0 -0
  150. /package/{compiler → transformer}/plugins/customElementReact/templates/_.gitignore.hbs +0 -0
  151. /package/{compiler → transformer}/plugins/customElementReact/templates/package.json.hbs +0 -0
  152. /package/{compiler → transformer}/plugins/customElementReact/templates/rollup.config.js.hbs +0 -0
  153. /package/{compiler → transformer}/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -0
  154. /package/{compiler → transformer}/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -0
  155. /package/{compiler → transformer}/plugins/customElementReact/templates/tsconfig.json.hbs +0 -0
  156. /package/{compiler → transformer}/plugins/index.d.ts +0 -0
  157. /package/{compiler → transformer}/plugins/index.js +0 -0
  158. /package/{types/context.js → transformer/transformer.types.js} +0 -0
  159. /package/{compiler → transformer}/utils/__dirname.d.ts +0 -0
  160. /package/{compiler → transformer}/utils/__dirname.js +0 -0
  161. /package/{compiler → transformer}/utils/addDependency.d.ts +0 -0
  162. /package/{compiler → transformer}/utils/addDependency.js +0 -0
  163. /package/{compiler → transformer}/utils/getInitializer.d.ts +0 -0
  164. /package/{compiler → transformer}/utils/getInitializer.js +0 -0
  165. /package/{compiler → transformer}/utils/getType.d.ts +0 -0
  166. /package/{compiler → transformer}/utils/getType.js +0 -0
  167. /package/{compiler → transformer}/utils/getTypeReference.d.ts +0 -0
  168. /package/{compiler → transformer}/utils/getTypeReference.js +0 -0
  169. /package/{compiler → transformer}/utils/hasDecorator.d.ts +0 -0
  170. /package/{compiler → transformer}/utils/hasDecorator.js +0 -0
  171. /package/{compiler → transformer}/utils/index.d.ts +0 -0
  172. /package/{compiler → transformer}/utils/index.js +0 -0
  173. /package/{compiler → transformer}/utils/isDirectoryEmpty.d.ts +0 -0
  174. /package/{compiler → transformer}/utils/isDirectoryEmpty.js +0 -0
  175. /package/{compiler → transformer}/utils/print.d.ts +0 -0
  176. /package/{compiler → transformer}/utils/print.js +0 -0
  177. /package/{compiler → transformer}/utils/printType.d.ts +0 -0
  178. /package/{compiler → transformer}/utils/removeUnusedImport.d.ts +0 -0
  179. /package/{compiler → transformer}/utils/removeUnusedImport.js +0 -0
  180. /package/{compiler → transformer}/utils/renderTemplate.d.ts +0 -0
  181. /package/{compiler → transformer}/utils/tags.d.ts +0 -0
  182. /package/{compiler → transformer}/utils/tags.js +0 -0
  183. /package/{compiler → transformer}/utils/visitor.d.ts +0 -0
  184. /package/{compiler → transformer}/utils/visitor.js +0 -0
@@ -1,6 +0,0 @@
1
- import { Context, Plugin } from '../types';
2
- export declare const compiler: (...plugins: Array<Plugin>) => {
3
- start: () => Promise<void>;
4
- run: (filePath: string) => Promise<Context>;
5
- finish: () => Promise<void>;
6
- };
@@ -1,2 +0,0 @@
1
- export * from './compiler.js';
2
- export * from './plugins/index.js';
package/compiler/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './compiler.js';
2
- export * from './plugins/index.js';
@@ -1,8 +0,0 @@
1
- import { Context, Plugin } from '../../types';
2
- export declare const ASSETS_OPTIONS: Partial<AssetsOptions>;
3
- export type AssetsOptions = {
4
- once?: boolean;
5
- destination: (context: Context) => string;
6
- source?: (context: Context) => string;
7
- };
8
- export declare const assets: (options: AssetsOptions) => Plugin;
@@ -1,33 +0,0 @@
1
- import fs from 'fs-extra';
2
- import path from 'path';
3
- export const ASSETS_OPTIONS = {
4
- once: true,
5
- destination(context) {
6
- return `assets/${context.fileName}`;
7
- },
8
- source(context) {
9
- return path.join(context.directoryPath, 'assets');
10
- }
11
- };
12
- export const assets = (options) => {
13
- const name = 'assets';
14
- options = Object.assign({}, ASSETS_OPTIONS, options);
15
- const sources = new Set();
16
- const run = (context) => {
17
- var _a, _b;
18
- const source = (_a = options.source) === null || _a === void 0 ? void 0 : _a.call(options, context);
19
- if (!source)
20
- return;
21
- if (!fs.existsSync(source))
22
- return;
23
- if (options.once) {
24
- if (sources.has(source))
25
- return;
26
- sources.add(source);
27
- }
28
- const destination = (_b = options.destination) === null || _b === void 0 ? void 0 : _b.call(options, context);
29
- fs.copySync(source, destination);
30
- context.assets = source;
31
- };
32
- return { name, run };
33
- };
@@ -1 +0,0 @@
1
- export * from './components';
@@ -1,7 +0,0 @@
1
- import { Context, Plugin } from '../../types';
2
- export declare const DOCUMENT_OPTIONS: Partial<DocumentOptions>;
3
- export interface DocumentOptions {
4
- destination: string;
5
- transformer?: (context: Context, element: any) => any;
6
- }
7
- export declare const document: (options: DocumentOptions) => Plugin;
@@ -1,2 +0,0 @@
1
- import { Plugin } from '../../types';
2
- export declare const extract: () => Plugin;
@@ -1,5 +0,0 @@
1
- import { ParserOptions } from '@babel/parser';
2
- import { Plugin } from '../../types';
3
- export declare const PARSE_OPTIONS: Partial<ParseOptions>;
4
- export type ParseOptions = ParserOptions;
5
- export declare const parse: (options?: ParseOptions) => Plugin;
@@ -1,8 +0,0 @@
1
- /// <reference types="node" />
2
- import { Plugin } from '../../types';
3
- export declare const READ_OPTIONS: Partial<ReadOptions>;
4
- export type ReadOptions = {
5
- encoding: BufferEncoding;
6
- flag?: string | undefined;
7
- };
8
- export declare const read: (options?: ReadOptions) => Plugin;
@@ -1,13 +0,0 @@
1
- import fs from 'fs-extra';
2
- export const READ_OPTIONS = {
3
- encoding: 'utf8'
4
- };
5
- export const read = (options) => {
6
- const name = 'read';
7
- options = Object.assign({}, READ_OPTIONS, options);
8
- const run = (context) => {
9
- var _a;
10
- context.fileContent = (_a = context.fileContent) !== null && _a !== void 0 ? _a : fs.readFileSync(context.filePath, options);
11
- };
12
- return { name, run };
13
- };
@@ -1,6 +0,0 @@
1
- import { Context, Plugin } from '../../types';
2
- export declare const README_OPTIONS: Partial<ReadmeOptions>;
3
- export type ReadmeOptions = {
4
- source?: (context: Context) => string;
5
- };
6
- export declare const readme: (options: ReadmeOptions) => Plugin;
@@ -1,6 +0,0 @@
1
- import { Context, Plugin } from '../../types';
2
- export declare const STYLE_OPTIONS: Partial<StyleOptions>;
3
- export type StyleOptions = {
4
- source?: (context: Context) => string | string[];
5
- };
6
- export declare const style: (options?: StyleOptions) => Plugin;
@@ -1,2 +0,0 @@
1
- import { Plugin } from '../../types';
2
- export declare const validate: () => Plugin;
@@ -1,37 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- import { hasDecorator, visitor } from '../utils/index.js';
3
- export const validate = () => {
4
- const name = 'validate';
5
- const run = (context) => {
6
- let hasValidImport;
7
- visitor(context.fileAST, {
8
- ImportDeclaration(path) {
9
- var _a;
10
- if (((_a = path.node.source) === null || _a === void 0 ? void 0 : _a.value) !== CONSTANTS.PACKAGE_NAME)
11
- return;
12
- for (const specifier of path.node.specifiers) {
13
- if (specifier.imported.name !== CONSTANTS.DECORATOR_ELEMENT)
14
- continue;
15
- hasValidImport = true;
16
- path.stop();
17
- }
18
- }
19
- });
20
- let hasValidExport;
21
- visitor(context.fileAST, {
22
- ExportNamedDeclaration(path) {
23
- if (hasValidExport) {
24
- hasValidExport = false;
25
- return path.stop();
26
- }
27
- if (path.node.declaration.type !== 'ClassDeclaration')
28
- return;
29
- if (!hasDecorator(path.node.declaration, CONSTANTS.DECORATOR_ELEMENT))
30
- return;
31
- hasValidExport = true;
32
- }
33
- });
34
- context.isInvalid = !hasValidImport || !hasValidExport;
35
- };
36
- return { name, run };
37
- };
@@ -1,8 +0,0 @@
1
- import { Context, Plugin } from '../../types';
2
- export declare const VISUAL_STUDIO_CODE_OPTIONS: Partial<VisualStudioCodeOptions>;
3
- export interface VisualStudioCodeOptions {
4
- destination: string;
5
- reference?: (context: Context) => string;
6
- transformer?: (context: Context, component: any) => any;
7
- }
8
- export declare const visualStudioCode: (options: VisualStudioCodeOptions) => Plugin;
@@ -1,10 +0,0 @@
1
- import { Context, Plugin } from '../../types';
2
- export declare const WEB_TYPES_OPTIONS: Partial<WebTypesOptions>;
3
- export interface WebTypesOptions {
4
- destination: string;
5
- packageName: string;
6
- packageVersion: string;
7
- reference?: (context: Context) => string;
8
- transformer?: (context: Context, component: any) => any;
9
- }
10
- export declare const webTypes: (options: WebTypesOptions) => Plugin;
@@ -1,31 +0,0 @@
1
- import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
2
- export interface Context {
3
- customElementNames?: Array<string>;
4
- isInvalid?: boolean;
5
- script?: string;
6
- assets?: string;
7
- class?: ClassDeclaration;
8
- classEvents?: Array<ClassProperty>;
9
- classHasMount?: boolean;
10
- classHasUnmount?: boolean;
11
- classMembers?: ClassBody['body'];
12
- classMethods?: Array<ClassMethod>;
13
- className?: string;
14
- classProperties?: Array<ClassProperty>;
15
- classRender?: ClassMethod;
16
- classStates?: Array<ClassProperty>;
17
- componentKey?: string;
18
- directoryName?: string;
19
- directoryPath?: string;
20
- fileAST?: File;
21
- fileContent?: string;
22
- fileExtension?: string;
23
- fileName?: string;
24
- filePath?: string;
25
- readmeContent?: string;
26
- readmePath?: string;
27
- styleContent?: string;
28
- styleDependencies?: Array<string>;
29
- styleParsed?: string;
30
- stylePath?: string;
31
- }
package/types/global.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { Context } from './context';
2
- export interface Global {
3
- contexts: Array<Context>;
4
- }
package/types/global.js DELETED
@@ -1 +0,0 @@
1
- export {};
package/types/plugin.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import { Context } from './context';
2
- import { Global } from './global';
3
- export type Return<T> = void | T | Promise<void | T>;
4
- export type Plugin = {
5
- name: string;
6
- options?: any;
7
- start?: (global: Global) => Return<Global>;
8
- run?: (context: Context, global: Global) => Return<Context>;
9
- finish?: (global: Global) => Return<Global>;
10
- };
package/types/plugin.js DELETED
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- export interface PlusElement {
2
- }
@@ -1 +0,0 @@
1
- export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes