@htmlplus/element 1.0.0 → 2.0.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 +3 -3
  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/transformer/plugins/document.d.ts +7 -0
  81. package/{compiler → transformer}/plugins/document.js +18 -18
  82. package/transformer/plugins/extract.d.ts +2 -0
  83. package/{compiler → transformer}/plugins/extract.js +1 -18
  84. package/{compiler → transformer}/plugins/index.d.ts +0 -1
  85. package/{compiler → transformer}/plugins/index.js +0 -1
  86. package/transformer/plugins/parse.d.ts +6 -0
  87. package/{compiler → transformer}/plugins/parse.js +1 -1
  88. package/transformer/plugins/read.d.ts +8 -0
  89. package/transformer/plugins/read.js +20 -0
  90. package/transformer/plugins/readme.d.ts +6 -0
  91. package/{compiler → transformer}/plugins/readme.js +3 -2
  92. package/transformer/plugins/style.d.ts +6 -0
  93. package/{compiler → transformer}/plugins/style.js +4 -2
  94. package/transformer/plugins/validate.d.ts +2 -0
  95. package/transformer/plugins/validate.js +41 -0
  96. package/transformer/plugins/visualStudioCode.d.ts +8 -0
  97. package/{compiler → transformer}/plugins/visualStudioCode.js +10 -8
  98. package/transformer/plugins/webTypes.d.ts +10 -0
  99. package/{compiler → transformer}/plugins/webTypes.js +11 -7
  100. package/transformer/transformer.d.ts +6 -0
  101. package/{compiler/compiler.js → transformer/transformer.js} +17 -17
  102. package/transformer/transformer.types.d.ts +50 -0
  103. package/{compiler → transformer}/utils/printType.js +2 -2
  104. package/{compiler → transformer}/utils/renderTemplate.js +2 -0
  105. package/types/index.d.ts +2 -4
  106. package/types/index.js +1 -4
  107. package/CHANGELOG.md +0 -7
  108. package/bundlers/index.d.ts +0 -2
  109. package/bundlers/index.js +0 -2
  110. package/client/helpers/index.d.ts +0 -1
  111. package/client/helpers/index.js +0 -1
  112. package/client/services/index.d.ts +0 -1
  113. package/client/services/index.js +0 -1
  114. package/client/services/link.d.ts +0 -4
  115. package/client/services/link.js +0 -196
  116. package/client/utils/getNamespace.d.ts +0 -2
  117. package/client/utils/getNamespace.js +0 -4
  118. package/client/vendors/uhtml.d.ts +0 -29
  119. package/client/vendors/uhtml.js +0 -700
  120. package/compiler/compiler.d.ts +0 -6
  121. package/compiler/index.d.ts +0 -2
  122. package/compiler/index.js +0 -2
  123. package/compiler/plugins/assets.d.ts +0 -8
  124. package/compiler/plugins/assets.js +0 -33
  125. package/compiler/plugins/customElementReact/customElementReact.d.ts +0 -16
  126. package/compiler/plugins/customElementReact/customElementReact.js +0 -97
  127. package/compiler/plugins/customElementReact/index.d.ts +0 -1
  128. package/compiler/plugins/customElementReact/index.js +0 -1
  129. package/compiler/plugins/customElementReact/templates/README.md.hbs +0 -1
  130. package/compiler/plugins/customElementReact/templates/_.gitignore.hbs +0 -2
  131. package/compiler/plugins/customElementReact/templates/package.json.hbs +0 -37
  132. package/compiler/plugins/customElementReact/templates/rollup.config.js.hbs +0 -21
  133. package/compiler/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -17
  134. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +0 -18
  135. package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +0 -23
  136. package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
  137. package/compiler/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -269
  138. package/compiler/plugins/customElementReact/templates/tsconfig.json.hbs +0 -17
  139. package/compiler/plugins/document.d.ts +0 -7
  140. package/compiler/plugins/extract.d.ts +0 -2
  141. package/compiler/plugins/parse.d.ts +0 -5
  142. package/compiler/plugins/read.d.ts +0 -8
  143. package/compiler/plugins/read.js +0 -13
  144. package/compiler/plugins/readme.d.ts +0 -6
  145. package/compiler/plugins/style.d.ts +0 -6
  146. package/compiler/plugins/validate.d.ts +0 -2
  147. package/compiler/plugins/validate.js +0 -37
  148. package/compiler/plugins/visualStudioCode.d.ts +0 -8
  149. package/compiler/plugins/webTypes.d.ts +0 -10
  150. package/types/context.d.ts +0 -31
  151. package/types/global.d.ts +0 -4
  152. package/types/global.js +0 -1
  153. package/types/plugin.d.ts +0 -10
  154. package/types/plugin.js +0 -1
  155. package/types/plusElement.d.ts +0 -2
  156. package/types/plusElement.js +0 -1
  157. /package/{compiler → transformer}/plugins/copy.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
@@ -2,8 +2,8 @@ import { print } from './print.js';
2
2
  // TODO
3
3
  // args types
4
4
  // return type
5
- // components\grid-item\grid-item.types.ts
6
- // components\portal\portal.tsx
5
+ // elements\grid-item\grid-item.types.ts
6
+ // elements\portal\portal.tsx
7
7
  export const printType = (ast) => {
8
8
  if (!ast)
9
9
  return ast;
@@ -5,7 +5,9 @@ import path from 'path';
5
5
  export const renderTemplate = (source, destination, options) => (context) => {
6
6
  const files = glob.sync(source, options);
7
7
  for (const file of files) {
8
+ // TODO
8
9
  const from = path.resolve((options === null || options === void 0 ? void 0 : options.cwd) || '', file);
10
+ // TODO
9
11
  const to = path.join(destination, path
10
12
  .normalize(file)
11
13
  .split(path.sep)
package/types/index.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- export * from './context';
2
- export * from './global';
3
- export * from './plugin';
4
- export * from './plusElement';
1
+ export interface PlusElement {
2
+ }
package/types/index.js CHANGED
@@ -1,4 +1 @@
1
- export * from './context';
2
- export * from './global';
3
- export * from './plugin';
4
- export * from './plusElement';
1
+ export {};
package/CHANGELOG.md DELETED
@@ -1,7 +0,0 @@
1
- # 1.0.0 (2023-12-03)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * **package:** fix mistake import ([40180d6](https://github.com/htmlplus/element/commit/40180d64ff1f7fcc4e9edc10c03431dfc8172fa3))
7
- * **prettier:** fix extra tabs ([22fbad9](https://github.com/htmlplus/element/commit/22fbad962636fd7a8ad53da64dd22078633e4147))
@@ -1,2 +0,0 @@
1
- export * from './rollup.js';
2
- export * from './vite.js';
package/bundlers/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './rollup.js';
2
- export * from './vite.js';
@@ -1 +0,0 @@
1
- export { classes, direction, getConfig, host, isRTL, isServer, on, off, slots, styles, toUnit, setConfig } from '../utils/index.js';
@@ -1 +0,0 @@
1
- export { classes, direction, getConfig, host, isRTL, isServer, on, off, slots, styles, toUnit, setConfig } from '../utils/index.js';
@@ -1 +0,0 @@
1
- export * from './link.js';
@@ -1 +0,0 @@
1
- export * from './link.js';
@@ -1,4 +0,0 @@
1
- export type LinkConfig = {
2
- scope?: Function;
3
- };
4
- export declare const createLink: (namespace: string) => any;
@@ -1,196 +0,0 @@
1
- import { defineProperty, host } from '../utils/index.js';
2
- const links = new Map();
3
- // TODO: return type
4
- export const createLink = (namespace) => {
5
- if (links.has(namespace))
6
- return links.get(namespace);
7
- const config = {
8
- scope: (i) => i.connector
9
- };
10
- let disconnecting = false;
11
- const children = new Map();
12
- const parents = new Map();
13
- const properties = [];
14
- const find = (source) => {
15
- return properties.find((destination) => destination.instance === source.instance && destination.name === source.name);
16
- };
17
- const register = (source) => {
18
- properties.push(source);
19
- if (!children.has(source.instance))
20
- children.set(source.instance, new Set());
21
- // TODO: any
22
- const siblings = children.get(source.instance);
23
- siblings.add(source);
24
- };
25
- const unregister = (source) => {
26
- // TODO: any
27
- source = find(source);
28
- const index = properties.findIndex((property) => property === source);
29
- if (index === -1)
30
- return;
31
- properties.splice(index, 1);
32
- // TODO: any
33
- const siblings = children.get(source.instance);
34
- siblings.delete(source);
35
- if (siblings.size)
36
- return;
37
- children.delete(source.instance);
38
- parents.delete(source.instance);
39
- };
40
- const get = (source) => {
41
- // TODO: any
42
- return source.instance[source.name];
43
- };
44
- const set = (source, value) => {
45
- // TODO: any
46
- source.instance[source.name] = value;
47
- };
48
- const reset = (source) => {
49
- if (source.type === 'action')
50
- return;
51
- if (source.type === 'inject')
52
- return set(source, source.value /* TODO */);
53
- // TODO: any
54
- defineProperty(source.instance, source.name, {
55
- value: get(source) /* TODO */,
56
- enumerable: true,
57
- configurable: true
58
- });
59
- };
60
- const map = (source, destination) => {
61
- let value = get(source);
62
- if (typeof value === 'function')
63
- value = value.bind(source.instance);
64
- set(destination, value);
65
- };
66
- const proxy = (source) => {
67
- let value = get(source);
68
- // TODO: any
69
- defineProperty(source.instance, source.name, {
70
- enumerable: true,
71
- configurable: true,
72
- get() {
73
- return value;
74
- },
75
- set(input) {
76
- if (input === value)
77
- return;
78
- value = input;
79
- siblings(source, ['inject']).map((destination) => set(destination, value));
80
- }
81
- });
82
- };
83
- const parent = (source) => {
84
- var _a;
85
- const cache = parents.get(source.instance);
86
- if (cache)
87
- return cache;
88
- // TODO: element? and any
89
- let parent = (_a = source.element) === null || _a === void 0 ? void 0 : _a.parentElement;
90
- while (parent) {
91
- if (parent.shadowRoot) {
92
- const item = properties.find((property) => property.element === parent && property.name === source.name);
93
- if (item) {
94
- parents.set(source.instance, item);
95
- return item;
96
- }
97
- }
98
- parent = parent.parentElement;
99
- }
100
- };
101
- const scope = (source) => {
102
- var _a, _b;
103
- if (!source)
104
- return;
105
- // TODO
106
- if (disconnecting)
107
- return source.instance['$scope-prev'];
108
- // TODO: &&
109
- let input = config.scope && config.scope(source.instance);
110
- if (typeof input !== 'undefined')
111
- return input;
112
- // TODO: any
113
- return ((_b = (_a = scope(parent(source))) !== null && _a !== void 0 ? _a : source.instance['$scope-auto']) !== null && _b !== void 0 ? _b : (source.instance['$scope-auto'] = Math.random()));
114
- };
115
- const siblings = (source, types) => {
116
- return properties.filter((destination) => {
117
- // TODO: any
118
- if (!types.includes(destination.type))
119
- return false;
120
- if (source === destination)
121
- return false;
122
- if (source.name !== destination.name)
123
- return false;
124
- if (scope(source) !== scope(destination))
125
- return false;
126
- return true;
127
- });
128
- };
129
- const connect = (source) => {
130
- // TODO
131
- source.instance['$scope-prev'] = scope(source);
132
- register(source);
133
- switch (source.type) {
134
- case 'action':
135
- siblings(source, ['inject']).forEach((destination) => map(source, destination));
136
- break;
137
- case 'observable':
138
- proxy(source);
139
- siblings(source, ['inject']).forEach((destination) => map(source, destination));
140
- break;
141
- case 'inject':
142
- siblings(source, ['action', 'observable']).forEach((destination) => map(destination, source));
143
- break;
144
- }
145
- };
146
- const disconnect = (source) => {
147
- reset(source);
148
- if (source.type === 'inject')
149
- return unregister(source);
150
- siblings(source, ['inject']).forEach(reset);
151
- unregister(source);
152
- };
153
- const reconnect = (instance) => {
154
- const p = properties.filter((property) => property.instance === instance);
155
- disconnecting = true;
156
- p.forEach(disconnect);
157
- disconnecting = false;
158
- p.forEach(connect);
159
- };
160
- const decorator = (type) => () => (target, name) => {
161
- const connected = target.connectedCallback;
162
- target.connectedCallback = function () {
163
- connected && connected.bind(this)();
164
- const property = {
165
- element: host(this),
166
- instance: this,
167
- name,
168
- type,
169
- value: this[name]
170
- };
171
- if (find(property))
172
- console.error('TODO: Error log');
173
- connect(property);
174
- };
175
- const disconnected = target.disconnectedCallback;
176
- target.disconnectedCallback = function () {
177
- disconnected && disconnected.bind(this)();
178
- const property = find({ instance: this, name });
179
- if (!property)
180
- console.error('TODO: Error log');
181
- // TODO: any
182
- disconnect(property);
183
- };
184
- };
185
- const Action = decorator('action');
186
- const Inject = decorator('inject');
187
- const Observable = decorator('observable');
188
- const result = {
189
- Action,
190
- Inject,
191
- Observable,
192
- reconnect
193
- };
194
- links.set(namespace, result);
195
- return result;
196
- };
@@ -1,2 +0,0 @@
1
- import { PlusElement } from '../../types';
2
- export declare const getNamespace: (instance: PlusElement) => string;
@@ -1,4 +0,0 @@
1
- import { getTag } from './getTag.js';
2
- export const getNamespace = (instance) => {
3
- return getTag(instance).split('-')[0].toUpperCase();
4
- };
@@ -1,29 +0,0 @@
1
- declare namespace _default {
2
- export { Hole };
3
- export { html };
4
- export { render };
5
- export { svg };
6
- }
7
- export default _default;
8
- /**
9
- * Holds all details wrappers needed to render the content further on.
10
- * @constructor
11
- * @param {string} type The hole type, either `html` or `svg`.
12
- * @param {string[]} template The template literals used to the define the content.
13
- * @param {Array} values Zero, one, or more interpolated values to render.
14
- */
15
- export class Hole {
16
- constructor(type: any, template: any, values: any);
17
- type: any;
18
- template: any;
19
- values: any;
20
- }
21
- export const html: ((template: any, ...values: any[]) => Hole) & {
22
- for(ref: any, id: any): any;
23
- node: (template: any, ...values: any[]) => any;
24
- };
25
- export function render(where: any, what: any): any;
26
- export const svg: ((template: any, ...values: any[]) => Hole) & {
27
- for(ref: any, id: any): any;
28
- node: (template: any, ...values: any[]) => any;
29
- };