@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.
- package/README.md +616 -534
- package/bundlers/rollup.d.ts +2 -2
- package/bundlers/rollup.js +5 -5
- package/bundlers/vite.d.ts +2 -2
- package/bundlers/vite.js +5 -5
- package/client/decorators/bind.d.ts +4 -0
- package/client/decorators/bind.js +4 -0
- package/client/decorators/direction.d.ts +5 -0
- package/client/decorators/direction.js +8 -0
- package/client/decorators/element.d.ts +5 -0
- package/client/decorators/element.js +7 -2
- package/client/decorators/event.d.ts +21 -7
- package/client/decorators/event.js +7 -2
- package/client/decorators/host.d.ts +4 -2
- package/client/decorators/host.js +5 -8
- package/client/decorators/index.d.ts +3 -0
- package/client/decorators/index.js +3 -0
- package/client/decorators/isRTL.d.ts +4 -0
- package/client/decorators/isRTL.js +7 -0
- package/client/decorators/listen.d.ts +38 -8
- package/client/decorators/listen.js +9 -12
- package/client/decorators/method.d.ts +4 -0
- package/client/decorators/method.js +4 -0
- package/client/decorators/property.d.ts +8 -1
- package/client/decorators/property.js +4 -0
- package/client/decorators/query.d.ts +9 -2
- package/client/decorators/query.js +10 -9
- package/client/decorators/queryAll.d.ts +12 -2
- package/client/decorators/queryAll.js +13 -9
- package/client/decorators/slots.d.ts +4 -0
- package/client/decorators/slots.js +7 -0
- package/client/decorators/state.d.ts +4 -0
- package/client/decorators/state.js +4 -0
- package/client/decorators/watch.d.ts +5 -4
- package/client/decorators/watch.js +5 -4
- package/client/index.d.ts +1 -3
- package/client/index.js +1 -3
- package/client/utils/classes.d.ts +3 -0
- package/client/utils/classes.js +11 -28
- package/client/utils/config.d.ts +25 -3
- package/client/utils/config.js +18 -10
- package/client/utils/direction.d.ts +5 -2
- package/client/utils/direction.js +5 -1
- package/client/utils/event.d.ts +6 -0
- package/client/utils/event.js +6 -0
- package/client/utils/host.d.ts +3 -0
- package/client/utils/host.js +3 -0
- package/client/utils/index.d.ts +4 -1
- package/client/utils/index.js +4 -1
- package/client/utils/isCSSColor.d.ts +5 -0
- package/client/utils/isCSSColor.js +9 -0
- package/client/utils/isRTL.d.ts +3 -0
- package/client/utils/isRTL.js +3 -0
- package/client/utils/isServer.d.ts +3 -0
- package/client/utils/isServer.js +3 -0
- package/client/utils/query.d.ts +5 -0
- package/client/utils/query.js +8 -0
- package/client/utils/queryAll.d.ts +5 -0
- package/client/utils/queryAll.js +8 -0
- package/client/utils/request.d.ts +1 -1
- package/client/utils/request.js +1 -1
- package/client/utils/slots.d.ts +3 -0
- package/client/utils/slots.js +6 -1
- package/client/utils/styles.d.ts +3 -0
- package/client/utils/styles.js +3 -0
- package/client/utils/toDecorator.d.ts +2 -0
- package/client/utils/toDecorator.js +10 -0
- package/client/utils/toUnit.d.ts +4 -1
- package/client/utils/toUnit.js +6 -3
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -0
- package/package.json +3 -3
- package/transformer/index.d.ts +3 -0
- package/transformer/index.js +3 -0
- package/transformer/plugins/assets.d.ts +8 -0
- package/transformer/plugins/assets.js +29 -0
- package/{compiler → transformer}/plugins/copy.d.ts +2 -2
- package/{compiler → transformer}/plugins/customElement.d.ts +2 -2
- package/{compiler → transformer}/plugins/customElement.js +13 -12
- package/transformer/plugins/document.d.ts +7 -0
- package/{compiler → transformer}/plugins/document.js +18 -18
- package/transformer/plugins/extract.d.ts +2 -0
- package/{compiler → transformer}/plugins/extract.js +1 -18
- package/{compiler → transformer}/plugins/index.d.ts +0 -1
- package/{compiler → transformer}/plugins/index.js +0 -1
- package/transformer/plugins/parse.d.ts +6 -0
- package/{compiler → transformer}/plugins/parse.js +1 -1
- package/transformer/plugins/read.d.ts +8 -0
- package/transformer/plugins/read.js +20 -0
- package/transformer/plugins/readme.d.ts +6 -0
- package/{compiler → transformer}/plugins/readme.js +3 -2
- package/transformer/plugins/style.d.ts +6 -0
- package/{compiler → transformer}/plugins/style.js +4 -2
- package/transformer/plugins/validate.d.ts +2 -0
- package/transformer/plugins/validate.js +41 -0
- package/transformer/plugins/visualStudioCode.d.ts +8 -0
- package/{compiler → transformer}/plugins/visualStudioCode.js +10 -8
- package/transformer/plugins/webTypes.d.ts +10 -0
- package/{compiler → transformer}/plugins/webTypes.js +11 -7
- package/transformer/transformer.d.ts +6 -0
- package/{compiler/compiler.js → transformer/transformer.js} +17 -17
- package/transformer/transformer.types.d.ts +50 -0
- package/{compiler → transformer}/utils/printType.js +2 -2
- package/{compiler → transformer}/utils/renderTemplate.js +2 -0
- package/types/index.d.ts +2 -4
- package/types/index.js +1 -4
- package/CHANGELOG.md +0 -7
- package/bundlers/index.d.ts +0 -2
- package/bundlers/index.js +0 -2
- package/client/helpers/index.d.ts +0 -1
- package/client/helpers/index.js +0 -1
- package/client/services/index.d.ts +0 -1
- package/client/services/index.js +0 -1
- package/client/services/link.d.ts +0 -4
- package/client/services/link.js +0 -196
- package/client/utils/getNamespace.d.ts +0 -2
- package/client/utils/getNamespace.js +0 -4
- package/client/vendors/uhtml.d.ts +0 -29
- package/client/vendors/uhtml.js +0 -700
- package/compiler/compiler.d.ts +0 -6
- package/compiler/index.d.ts +0 -2
- package/compiler/index.js +0 -2
- package/compiler/plugins/assets.d.ts +0 -8
- package/compiler/plugins/assets.js +0 -33
- package/compiler/plugins/customElementReact/customElementReact.d.ts +0 -16
- package/compiler/plugins/customElementReact/customElementReact.js +0 -97
- package/compiler/plugins/customElementReact/index.d.ts +0 -1
- package/compiler/plugins/customElementReact/index.js +0 -1
- package/compiler/plugins/customElementReact/templates/README.md.hbs +0 -1
- package/compiler/plugins/customElementReact/templates/_.gitignore.hbs +0 -2
- package/compiler/plugins/customElementReact/templates/package.json.hbs +0 -37
- package/compiler/plugins/customElementReact/templates/rollup.config.js.hbs +0 -21
- package/compiler/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -17
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +0 -18
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +0 -23
- package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
- package/compiler/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -269
- package/compiler/plugins/customElementReact/templates/tsconfig.json.hbs +0 -17
- package/compiler/plugins/document.d.ts +0 -7
- package/compiler/plugins/extract.d.ts +0 -2
- package/compiler/plugins/parse.d.ts +0 -5
- package/compiler/plugins/read.d.ts +0 -8
- package/compiler/plugins/read.js +0 -13
- package/compiler/plugins/readme.d.ts +0 -6
- package/compiler/plugins/style.d.ts +0 -6
- package/compiler/plugins/validate.d.ts +0 -2
- package/compiler/plugins/validate.js +0 -37
- package/compiler/plugins/visualStudioCode.d.ts +0 -8
- package/compiler/plugins/webTypes.d.ts +0 -10
- package/types/context.d.ts +0 -31
- package/types/global.d.ts +0 -4
- package/types/global.js +0 -1
- package/types/plugin.d.ts +0 -10
- package/types/plugin.js +0 -1
- package/types/plusElement.d.ts +0 -2
- package/types/plusElement.js +0 -1
- /package/{compiler → transformer}/plugins/copy.js +0 -0
- /package/{types/context.js → transformer/transformer.types.js} +0 -0
- /package/{compiler → transformer}/utils/__dirname.d.ts +0 -0
- /package/{compiler → transformer}/utils/__dirname.js +0 -0
- /package/{compiler → transformer}/utils/addDependency.d.ts +0 -0
- /package/{compiler → transformer}/utils/addDependency.js +0 -0
- /package/{compiler → transformer}/utils/getInitializer.d.ts +0 -0
- /package/{compiler → transformer}/utils/getInitializer.js +0 -0
- /package/{compiler → transformer}/utils/getType.d.ts +0 -0
- /package/{compiler → transformer}/utils/getType.js +0 -0
- /package/{compiler → transformer}/utils/getTypeReference.d.ts +0 -0
- /package/{compiler → transformer}/utils/getTypeReference.js +0 -0
- /package/{compiler → transformer}/utils/hasDecorator.d.ts +0 -0
- /package/{compiler → transformer}/utils/hasDecorator.js +0 -0
- /package/{compiler → transformer}/utils/index.d.ts +0 -0
- /package/{compiler → transformer}/utils/index.js +0 -0
- /package/{compiler → transformer}/utils/isDirectoryEmpty.d.ts +0 -0
- /package/{compiler → transformer}/utils/isDirectoryEmpty.js +0 -0
- /package/{compiler → transformer}/utils/print.d.ts +0 -0
- /package/{compiler → transformer}/utils/print.js +0 -0
- /package/{compiler → transformer}/utils/printType.d.ts +0 -0
- /package/{compiler → transformer}/utils/removeUnusedImport.d.ts +0 -0
- /package/{compiler → transformer}/utils/removeUnusedImport.js +0 -0
- /package/{compiler → transformer}/utils/renderTemplate.d.ts +0 -0
- /package/{compiler → transformer}/utils/tags.d.ts +0 -0
- /package/{compiler → transformer}/utils/tags.js +0 -0
- /package/{compiler → transformer}/utils/visitor.d.ts +0 -0
- /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
|
-
//
|
|
6
|
-
//
|
|
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
package/types/index.js
CHANGED
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))
|
package/bundlers/index.d.ts
DELETED
package/bundlers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { classes, direction, getConfig, host, isRTL, isServer, on, off, slots, styles, toUnit, setConfig } from '../utils/index.js';
|
package/client/helpers/index.js
DELETED
|
@@ -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';
|
package/client/services/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './link.js';
|
package/client/services/link.js
DELETED
|
@@ -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,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
|
-
};
|