@htmlplus/element 0.3.1 → 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 (158) hide show
  1. package/README.md +2 -2
  2. package/client/decorators/attributes.d.ts +2 -0
  3. package/client/decorators/attributes.js +13 -0
  4. package/client/decorators/bind.d.ts +4 -0
  5. package/client/decorators/bind.js +17 -0
  6. package/client/decorators/element.d.ts +2 -0
  7. package/client/decorators/element.js +53 -0
  8. package/client/decorators/event.d.ts +21 -0
  9. package/client/decorators/event.js +17 -0
  10. package/client/decorators/index.d.ts +9 -0
  11. package/client/decorators/index.js +9 -0
  12. package/client/decorators/listen.d.ts +12 -0
  13. package/client/decorators/listen.js +31 -0
  14. package/client/decorators/method.d.ts +2 -0
  15. package/client/decorators/method.js +11 -0
  16. package/client/decorators/property.d.ts +8 -0
  17. package/client/decorators/property.js +45 -0
  18. package/client/decorators/state.d.ts +2 -0
  19. package/client/decorators/state.js +23 -0
  20. package/client/decorators/watch.d.ts +8 -0
  21. package/client/decorators/watch.js +34 -0
  22. package/client/helpers/classes.d.ts +1 -0
  23. package/client/helpers/classes.js +62 -0
  24. package/client/helpers/direction.d.ts +3 -0
  25. package/client/helpers/direction.js +4 -0
  26. package/client/helpers/index.d.ts +9 -0
  27. package/client/helpers/index.js +9 -0
  28. package/client/helpers/isRTL.d.ts +2 -0
  29. package/client/helpers/isRTL.js +2 -0
  30. package/client/helpers/query.d.ts +3 -0
  31. package/client/helpers/query.js +5 -0
  32. package/client/helpers/queryAll.d.ts +3 -0
  33. package/client/helpers/queryAll.js +5 -0
  34. package/client/helpers/slots.d.ts +6 -0
  35. package/client/helpers/slots.js +15 -0
  36. package/client/helpers/styles.d.ts +1 -0
  37. package/client/helpers/styles.js +17 -0
  38. package/client/helpers/toUnit.d.ts +1 -0
  39. package/client/helpers/toUnit.js +7 -0
  40. package/client/index.d.ts +3 -0
  41. package/client/index.js +3 -0
  42. package/client/services/index.d.ts +1 -0
  43. package/client/services/index.js +1 -0
  44. package/client/services/link.d.ts +4 -0
  45. package/client/services/link.js +196 -0
  46. package/client/utils/appendToMethod.d.ts +2 -0
  47. package/client/utils/appendToMethod.js +7 -0
  48. package/client/utils/call.d.ts +2 -0
  49. package/client/utils/call.js +4 -0
  50. package/client/utils/defineProperty.d.ts +1 -0
  51. package/client/utils/defineProperty.js +1 -0
  52. package/client/utils/event.d.ts +5 -0
  53. package/client/utils/event.js +9 -0
  54. package/client/utils/getMembers.d.ts +2 -0
  55. package/client/utils/getMembers.js +5 -0
  56. package/client/utils/getStyles.d.ts +2 -0
  57. package/client/utils/getStyles.js +5 -0
  58. package/client/utils/host.d.ts +2 -0
  59. package/client/utils/host.js +4 -0
  60. package/client/utils/index.d.ts +17 -0
  61. package/client/utils/index.js +17 -0
  62. package/client/utils/isEvent.d.ts +1 -0
  63. package/client/utils/isEvent.js +3 -0
  64. package/client/utils/isServer.d.ts +1 -0
  65. package/client/utils/isServer.js +3 -0
  66. package/client/utils/parseValue.d.ts +1 -0
  67. package/client/utils/parseValue.js +15 -0
  68. package/client/utils/request.d.ts +4 -0
  69. package/client/utils/request.js +38 -0
  70. package/client/utils/sync.d.ts +1 -0
  71. package/client/utils/sync.js +31 -0
  72. package/client/utils/task.d.ts +6 -0
  73. package/client/utils/task.js +37 -0
  74. package/client/utils/toBoolean.d.ts +1 -0
  75. package/client/utils/toBoolean.js +3 -0
  76. package/client/utils/toEvent.d.ts +1 -0
  77. package/client/utils/toEvent.js +3 -0
  78. package/client/utils/typeOf.d.ts +3 -0
  79. package/client/utils/typeOf.js +6 -0
  80. package/client/utils/updateAttribute.d.ts +1 -0
  81. package/client/utils/updateAttribute.js +7 -0
  82. package/client/vendor/uhtml.d.ts +22 -0
  83. package/client/vendor/uhtml.js +700 -0
  84. package/compiler/compiler.d.ts +7 -0
  85. package/compiler/compiler.js +72 -0
  86. package/compiler/index.d.ts +2 -0
  87. package/compiler/index.js +2 -0
  88. package/compiler/plugins/customElement.d.ts +8 -0
  89. package/compiler/plugins/customElement.js +157 -0
  90. package/compiler/plugins/customElementReact/customElementReact.d.ts +12 -0
  91. package/compiler/plugins/customElementReact/customElementReact.js +129 -0
  92. package/compiler/plugins/customElementReact/index.d.ts +1 -0
  93. package/compiler/plugins/customElementReact/index.js +1 -0
  94. package/compiler/plugins/customElementReact/templates/README.md.hbs +1 -0
  95. package/compiler/plugins/customElementReact/templates/_.gitignore.hbs +2 -0
  96. package/compiler/plugins/customElementReact/templates/package.json.hbs +37 -0
  97. package/compiler/plugins/customElementReact/templates/rollup.config.js.hbs +21 -0
  98. package/compiler/plugins/customElementReact/templates/src/components/index.ts.hbs +17 -0
  99. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +18 -0
  100. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +26 -0
  101. package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +1 -0
  102. package/compiler/plugins/customElementReact/templates/src/proxy.ts.hbs +278 -0
  103. package/compiler/plugins/customElementReact/templates/tsconfig.json.hbs +17 -0
  104. package/compiler/plugins/document.d.ts +10 -0
  105. package/compiler/plugins/document.js +254 -0
  106. package/compiler/plugins/external.d.ts +9 -0
  107. package/compiler/plugins/external.js +25 -0
  108. package/compiler/plugins/extract.d.ts +8 -0
  109. package/compiler/plugins/extract.js +62 -0
  110. package/compiler/plugins/index.d.ts +9 -0
  111. package/compiler/plugins/index.js +9 -0
  112. package/compiler/plugins/parse.d.ts +5 -0
  113. package/compiler/plugins/parse.js +16 -0
  114. package/compiler/plugins/read.d.ts +5 -0
  115. package/compiler/plugins/read.js +13 -0
  116. package/compiler/plugins/style.d.ts +10 -0
  117. package/compiler/plugins/style.js +36 -0
  118. package/compiler/plugins/validate.d.ts +5 -0
  119. package/compiler/plugins/validate.js +40 -0
  120. package/compiler/plugins/vscode.d.ts +11 -0
  121. package/compiler/plugins/vscode.js +83 -0
  122. package/compiler/utils/__dirname.d.ts +1 -0
  123. package/compiler/utils/__dirname.js +5 -0
  124. package/compiler/utils/getInitializer.d.ts +2 -0
  125. package/compiler/utils/getInitializer.js +10 -0
  126. package/compiler/utils/getType.d.ts +2 -0
  127. package/compiler/utils/getType.js +69 -0
  128. package/compiler/utils/getTypeReference.d.ts +2 -0
  129. package/compiler/utils/getTypeReference.js +33 -0
  130. package/compiler/utils/hasDecorator.d.ts +1 -0
  131. package/compiler/utils/hasDecorator.js +5 -0
  132. package/compiler/utils/index.d.ts +11 -0
  133. package/compiler/utils/index.js +11 -0
  134. package/compiler/utils/isDirectoryEmpty.d.ts +1 -0
  135. package/compiler/utils/isDirectoryEmpty.js +10 -0
  136. package/compiler/utils/print.d.ts +2 -0
  137. package/compiler/utils/print.js +5 -0
  138. package/compiler/utils/printType.d.ts +1 -0
  139. package/compiler/utils/printType.js +69 -0
  140. package/compiler/utils/renderTemplate.d.ts +1 -0
  141. package/compiler/utils/renderTemplate.js +25 -0
  142. package/compiler/utils/tags.d.ts +13 -0
  143. package/compiler/utils/tags.js +53 -0
  144. package/compiler/utils/visitor.d.ts +2 -0
  145. package/compiler/utils/visitor.js +5 -0
  146. package/constants/index.d.ts +22 -0
  147. package/constants/index.js +28 -0
  148. package/package.json +14 -17
  149. package/types/context.d.ts +38 -0
  150. package/types/context.js +1 -0
  151. package/types/global.d.ts +4 -0
  152. package/types/global.js +1 -0
  153. package/types/index.d.ts +4 -0
  154. package/types/index.js +4 -0
  155. package/types/plugin.d.ts +10 -0
  156. package/types/plugin.js +1 -0
  157. package/types/plusElement.d.ts +2 -0
  158. package/types/plusElement.js +1 -0
@@ -0,0 +1,28 @@
1
+ export const PACKAGE_NAME = '@htmlplus/element';
2
+ // apis
3
+ export const API_HOST = '$host$';
4
+ export const API_READY = '$ready$';
5
+ // decorators
6
+ export const DECORATOR_ELEMENT = 'Element';
7
+ export const DECORATOR_EVENT = 'Event';
8
+ export const DECORATOR_PROPERTY = 'Property';
9
+ export const DECORATOR_STATE = 'State';
10
+ export const DECORATOR_METHOD = 'Method';
11
+ // lifecycle
12
+ export const LIFECYCLE_ADOPTED = 'adoptedCallback';
13
+ export const LIFECYCLE_CONNECTED = 'connectedCallback';
14
+ export const LIFECYCLE_DISCONNECTED = 'disconnectedCallback';
15
+ export const LIFECYCLE_LOADED = 'loadedCallback';
16
+ export const LIFECYCLE_UPDATE = 'updateCallback';
17
+ export const LIFECYCLE_UPDATED = 'updatedCallback';
18
+ // methods
19
+ export const METHOD_RENDER = 'render';
20
+ // statics
21
+ export const STATIC_MEMBERS = 'members';
22
+ export const STATIC_STYLES = 'styles';
23
+ // types
24
+ export const TYPE_BOOLEAN = 'boolean';
25
+ export const TYPE_DATE = 'date';
26
+ export const TYPE_FUNCTION = 'function';
27
+ export const TYPE_STRING = 'string';
28
+ export const TYPE_NUMBER = 'number';
package/package.json CHANGED
@@ -1,22 +1,12 @@
1
1
  {
2
2
  "name": "@htmlplus/element",
3
- "version": "0.3.1",
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
+ }
@@ -0,0 +1,38 @@
1
+ import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
2
+ export interface Context {
3
+ dependencies?: Array<Context>;
4
+ dependenciesUnresolved?: Array<string>;
5
+ isInvalid?: boolean;
6
+ script?: string;
7
+ outputs?: Array<{
8
+ name: string;
9
+ options?: any;
10
+ output?: any;
11
+ }>;
12
+ componentClassName?: string;
13
+ componentClassNamePrune?: string;
14
+ componentInterfaceName?: string;
15
+ componentKey?: string;
16
+ componentTag?: string;
17
+ directoryName?: string;
18
+ directoryPath?: string;
19
+ fileAST?: File;
20
+ fileContent?: string;
21
+ fileExtension?: string;
22
+ fileName?: string;
23
+ filePath?: string;
24
+ styleContent?: string;
25
+ styleDependencies?: Array<string>;
26
+ styleParsed?: string;
27
+ stylePath?: string;
28
+ class?: ClassDeclaration;
29
+ classEvents?: Array<ClassProperty>;
30
+ classHasMount?: boolean;
31
+ classHasUnmount?: boolean;
32
+ classMembers?: ClassBody['body'];
33
+ classMethods?: Array<ClassMethod>;
34
+ className?: string;
35
+ classProperties?: Array<ClassProperty>;
36
+ classRender?: ClassMethod;
37
+ classStates?: Array<ClassProperty>;
38
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import { Context } from './context.js';
2
+ export interface Global {
3
+ contexts: Array<Context>;
4
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './context.js';
2
+ export * from './global.js';
3
+ export * from './plugin.js';
4
+ export * from './plusElement.js';
package/types/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from './context.js';
2
+ export * from './global.js';
3
+ export * from './plugin.js';
4
+ export * from './plusElement.js';
@@ -0,0 +1,10 @@
1
+ import { Context } from './context.js';
2
+ import { Global } from './global';
3
+ export declare type Return<T> = void | T | Promise<T>;
4
+ export declare type Plugin = {
5
+ name: string;
6
+ options?: any;
7
+ start?: (global: Global) => Return<void>;
8
+ next?: (context: Context, global: Global) => Return<any>;
9
+ finish?: (global: Global) => Return<void>;
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export interface PlusElement {
2
+ }
@@ -0,0 +1 @@
1
+ export {};