@htmlplus/element 0.3.2 → 0.4.1
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 +2 -2
- package/client/decorators/attributes.js +3 -3
- package/client/decorators/element.js +11 -4
- package/client/decorators/event.js +2 -3
- package/client/decorators/listen.js +2 -1
- package/client/decorators/method.js +4 -5
- package/client/decorators/property.d.ts +0 -4
- package/client/decorators/property.js +38 -43
- package/client/decorators/state.js +17 -26
- package/client/decorators/watch.d.ts +7 -1
- package/client/decorators/watch.js +24 -10
- package/client/helpers/classes.d.ts +1 -1
- package/client/helpers/index.d.ts +3 -3
- package/client/helpers/index.js +3 -3
- package/client/helpers/{is-rtl.d.ts → isRTL.d.ts} +0 -0
- package/client/helpers/{is-rtl.js → isRTL.js} +0 -0
- package/client/helpers/{query-all.d.ts → queryAll.d.ts} +0 -0
- package/client/helpers/{query-all.js → queryAll.js} +0 -0
- package/client/helpers/slots.js +1 -1
- package/client/helpers/styles.js +2 -1
- package/client/helpers/{to-unit.d.ts → toUnit.d.ts} +0 -0
- package/client/helpers/{to-unit.js → toUnit.js} +0 -0
- package/client/utils/{append-to-method.d.ts → appendToMethod.d.ts} +0 -0
- package/client/utils/{append-to-method.js → appendToMethod.js} +0 -0
- package/client/utils/{define-property.d.ts → defineProperty.d.ts} +0 -0
- package/client/utils/{define-property.js → defineProperty.js} +0 -0
- package/client/utils/event.d.ts +5 -2
- package/client/utils/event.js +7 -4
- package/client/utils/{get-members.d.ts → getMembers.d.ts} +0 -0
- package/client/utils/{get-members.js → getMembers.js} +0 -0
- package/client/utils/{get-styles.d.ts → getStyles.d.ts} +0 -0
- package/client/utils/{get-styles.js → getStyles.js} +0 -0
- package/client/utils/index.d.ts +11 -14
- package/client/utils/index.js +11 -14
- package/client/utils/{is-event.d.ts → isEvent.d.ts} +0 -0
- package/client/utils/{is-event.js → isEvent.js} +0 -0
- package/client/utils/{is-server.d.ts → isServer.d.ts} +0 -0
- package/client/utils/{is-server.js → isServer.js} +0 -0
- package/client/utils/{parse-value.d.ts → parseValue.d.ts} +0 -0
- package/client/utils/{parse-value.js → parseValue.js} +2 -2
- package/client/utils/request.d.ts +3 -1
- package/client/utils/request.js +15 -5
- package/client/utils/sync.js +3 -3
- package/client/utils/{to-boolean.d.ts → toBoolean.d.ts} +0 -0
- package/client/utils/{to-boolean.js → toBoolean.js} +0 -0
- package/client/utils/{to-event.d.ts → toEvent.d.ts} +0 -0
- package/client/utils/{to-event.js → toEvent.js} +0 -0
- package/client/utils/{type-of.d.ts → typeOf.d.ts} +0 -0
- package/client/utils/{type-of.js → typeOf.js} +0 -0
- package/client/utils/{update-attribute.d.ts → updateAttribute.d.ts} +0 -0
- package/client/utils/{update-attribute.js → updateAttribute.js} +0 -0
- package/client/vendor/uhtml.d.ts +22 -0
- package/client/vendor/uhtml.js +700 -0
- package/compiler/compiler.js +42 -22
- package/compiler/plugins/customElement.d.ts +4 -1
- package/compiler/plugins/customElement.js +96 -77
- package/compiler/plugins/customElementReact/customElementReact.d.ts +1 -1
- package/compiler/plugins/customElementReact/customElementReact.js +12 -8
- package/compiler/plugins/customElementReact/templates/package.json.hbs +2 -2
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +4 -4
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +1 -1
- package/compiler/plugins/{docs.d.ts → document.d.ts} +3 -4
- package/compiler/plugins/document.js +254 -0
- package/compiler/plugins/external.d.ts +9 -0
- package/compiler/plugins/external.js +25 -0
- package/compiler/plugins/extract.d.ts +1 -1
- package/compiler/plugins/extract.js +3 -11
- package/compiler/plugins/index.d.ts +2 -0
- package/compiler/plugins/index.js +2 -0
- package/compiler/plugins/style.js +1 -1
- package/compiler/utils/{get-initializer.d.ts → getInitializer.d.ts} +0 -0
- package/compiler/utils/{get-initializer.js → getInitializer.js} +0 -0
- package/compiler/utils/{get-type.d.ts → getType.d.ts} +0 -0
- package/compiler/utils/{get-type.js → getType.js} +0 -0
- package/compiler/utils/getTypeReference.d.ts +2 -0
- package/compiler/utils/getTypeReference.js +33 -0
- package/compiler/utils/{has-decorator.d.ts → hasDecorator.d.ts} +0 -0
- package/compiler/utils/{has-decorator.js → hasDecorator.js} +0 -0
- package/compiler/utils/index.d.ts +8 -7
- package/compiler/utils/index.js +8 -7
- package/compiler/utils/{is-directory-empty.d.ts → isDirectoryEmpty.d.ts} +0 -0
- package/compiler/utils/{is-directory-empty.js → isDirectoryEmpty.js} +0 -0
- package/compiler/utils/{print-type.d.ts → printType.d.ts} +0 -0
- package/compiler/utils/{print-type.js → printType.js} +0 -0
- package/compiler/utils/{render-template.d.ts → renderTemplate.d.ts} +0 -0
- package/compiler/utils/{render-template.js → renderTemplate.js} +0 -0
- package/compiler/utils/tags.d.ts +13 -0
- package/compiler/utils/tags.js +53 -0
- package/constants/index.d.ts +1 -2
- package/constants/index.js +2 -2
- package/package.json +22 -27
- package/types/context.d.ts +6 -0
- package/types/index.d.ts +1 -1
- package/types/index.js +1 -1
- package/types/plugin.d.ts +4 -3
- package/types/{plus-element.d.ts → plusElement.d.ts} +0 -0
- package/types/{plus-element.js → plusElement.js} +0 -0
- package/client/utils/is-ready.d.ts +0 -2
- package/client/utils/is-ready.js +0 -4
- package/client/utils/on-ready.d.ts +0 -2
- package/client/utils/on-ready.js +0 -6
- package/client/utils/render.d.ts +0 -2
- package/client/utils/render.js +0 -19
- package/compiler/plugins/componentDependencyResolver.d.ts +0 -5
- package/compiler/plugins/componentDependencyResolver.js +0 -40
- package/compiler/plugins/docs.js +0 -320
- package/compiler/utils/get-tags.d.ts +0 -6
- package/compiler/utils/get-tags.js +0 -34
- package/runtime/index.d.ts +0 -1
- package/runtime/index.js +0 -4
package/compiler/compiler.js
CHANGED
|
@@ -1,51 +1,71 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
1
|
+
import ora from 'ora';
|
|
2
|
+
const logger = ora({
|
|
3
|
+
color: 'yellow'
|
|
4
|
+
});
|
|
6
5
|
export default (...plugins) => {
|
|
7
6
|
let global = {
|
|
8
7
|
contexts: []
|
|
9
8
|
};
|
|
9
|
+
logger.start(`${plugins.length} Plugins found.`).succeed();
|
|
10
10
|
const start = async () => {
|
|
11
|
-
|
|
11
|
+
logger.start('Starting...').succeed();
|
|
12
12
|
for (const plugin of plugins) {
|
|
13
|
-
if (plugin.start)
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
13
|
+
if (!plugin.start)
|
|
14
|
+
continue;
|
|
15
|
+
logger.start(`Plugin '${plugin.name}' starting...`);
|
|
16
|
+
await plugin.start(global);
|
|
17
|
+
logger.start(`Plugin '${plugin.name}' started successfully.`);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
+
logger.start(`Plugins started successfully.`).succeed();
|
|
19
20
|
};
|
|
20
21
|
const next = async (filePath) => {
|
|
22
|
+
var _a;
|
|
21
23
|
const key = filePath.split(/[\/|\\]/g).pop();
|
|
22
24
|
let context = {
|
|
23
25
|
filePath
|
|
24
26
|
};
|
|
25
|
-
|
|
27
|
+
let timeout;
|
|
26
28
|
for (const plugin of plugins) {
|
|
27
29
|
if (!plugin.next)
|
|
28
30
|
continue;
|
|
29
|
-
|
|
31
|
+
clearTimeout(timeout);
|
|
32
|
+
logger.start(`Plugin '${plugin.name}' executing...`);
|
|
33
|
+
const output = await plugin.next(context, global);
|
|
34
|
+
logger.start(`Plugin '${plugin.name}' executed successfully.`);
|
|
35
|
+
timeout = setTimeout(() => logger.stop(), 1500);
|
|
36
|
+
// TODO
|
|
37
|
+
if (output) {
|
|
38
|
+
context.outputs = ((_a = context.outputs) !== null && _a !== void 0 ? _a : [])
|
|
39
|
+
.filter((output) => {
|
|
40
|
+
if (plugin.name != output.name)
|
|
41
|
+
return true;
|
|
42
|
+
if (plugin.options && plugin.options != output.options)
|
|
43
|
+
return true;
|
|
44
|
+
})
|
|
45
|
+
.concat({
|
|
46
|
+
name: plugin.name,
|
|
47
|
+
options: plugin.options,
|
|
48
|
+
output
|
|
49
|
+
});
|
|
50
|
+
}
|
|
30
51
|
global.contexts = global.contexts.filter((current) => current.filePath != context.filePath).concat(context);
|
|
31
52
|
if (context.isInvalid)
|
|
32
53
|
break;
|
|
33
54
|
}
|
|
34
55
|
if (context.isInvalid)
|
|
35
|
-
|
|
36
|
-
else
|
|
37
|
-
log(key, 'Executed successfully.');
|
|
56
|
+
logger.start(`File '${key}' break executing because file is invalid.`).succeed();
|
|
38
57
|
return context;
|
|
39
58
|
};
|
|
40
59
|
const finish = async () => {
|
|
41
|
-
|
|
60
|
+
logger.start('Finishing...').succeed();
|
|
42
61
|
for (const plugin of plugins) {
|
|
43
|
-
if (plugin.finish)
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
62
|
+
if (!plugin.finish)
|
|
63
|
+
continue;
|
|
64
|
+
logger.start(`Plugin '${plugin.name}' finishing...`);
|
|
65
|
+
await plugin.finish(global);
|
|
66
|
+
logger.start(`Plugin '${plugin.name}' finished successfully.`);
|
|
47
67
|
}
|
|
48
|
-
|
|
68
|
+
logger.start(`Plugins finished successfully.`).succeed();
|
|
49
69
|
};
|
|
50
70
|
return {
|
|
51
71
|
start,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { Context } from '../../types/index.js';
|
|
2
|
-
export
|
|
2
|
+
export interface CustomElementOptions {
|
|
3
|
+
typings?: boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare const customElement: (options?: CustomElementOptions) => {
|
|
3
6
|
name: string;
|
|
4
7
|
next: (context: Context) => void;
|
|
5
8
|
};
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import t from '@babel/types';
|
|
2
2
|
import * as CONSTANTS from '../../constants/index.js';
|
|
3
3
|
import { print, visitor } from '../utils/index.js';
|
|
4
|
-
|
|
4
|
+
const defaults = {
|
|
5
|
+
typings: true
|
|
6
|
+
};
|
|
7
|
+
export const customElement = (options) => {
|
|
5
8
|
const name = 'customElement';
|
|
9
|
+
options = Object.assign({}, defaults, options);
|
|
6
10
|
const next = (context) => {
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
const ast = t.cloneNode(context.fileAST, true);
|
|
12
|
+
// TODO
|
|
13
|
+
visitor(ast, {
|
|
14
|
+
ClassDeclaration(path) {
|
|
15
|
+
if (path.node.id.name != context.className)
|
|
16
|
+
return;
|
|
17
|
+
path.node.body.body.unshift(t.classProperty(t.identifier('uhtml')));
|
|
18
|
+
}
|
|
19
|
+
});
|
|
9
20
|
// jsx to uhtml syntax
|
|
10
|
-
visitor(
|
|
21
|
+
visitor(ast, {
|
|
11
22
|
JSXAttribute: {
|
|
12
23
|
exit(path) {
|
|
13
24
|
var _a;
|
|
@@ -29,14 +40,14 @@ export const customElement = () => {
|
|
|
29
40
|
return;
|
|
30
41
|
}
|
|
31
42
|
else {
|
|
32
|
-
path.replaceWith(t.identifier('
|
|
43
|
+
path.replaceWith(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('uhtml')), t.identifier(`html\`${print(path.node)}\``)));
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
47
|
},
|
|
37
48
|
JSXFragment: {
|
|
38
49
|
exit(path) {
|
|
39
|
-
path.replaceWith(t.identifier(['html`', ...path.node.children.map((child) => print(child)), '`'].join('')));
|
|
50
|
+
path.replaceWith(t.memberExpression(t.memberExpression(t.thisExpression(), t.identifier('uhtml')), t.identifier(['html`', ...path.node.children.map((child) => print(child)), '`'].join(''))));
|
|
40
51
|
}
|
|
41
52
|
},
|
|
42
53
|
JSXExpressionContainer: {
|
|
@@ -55,81 +66,89 @@ export const customElement = () => {
|
|
|
55
66
|
}
|
|
56
67
|
});
|
|
57
68
|
// attach members
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
case 'TSBooleanKeyword':
|
|
65
|
-
elements.push(t.stringLiteral(CONSTANTS.TYPE_BOOLEAN));
|
|
66
|
-
break;
|
|
67
|
-
case 'TSStringKeyword':
|
|
68
|
-
elements.push(t.stringLiteral(CONSTANTS.TYPE_STRING));
|
|
69
|
-
break;
|
|
70
|
-
case 'TSNumberKeyword':
|
|
71
|
-
elements.push(t.stringLiteral(CONSTANTS.TYPE_NUMBER));
|
|
72
|
-
break;
|
|
73
|
-
default:
|
|
74
|
-
elements.push(t.nullLiteral());
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
if (property.value)
|
|
78
|
-
elements.push(property.value);
|
|
79
|
-
return t.objectProperty(t.identifier(property.key['name']), t.arrayExpression(elements));
|
|
80
|
-
}),
|
|
81
|
-
...context.classMethods.map((method) => {
|
|
82
|
-
const elements = [t.stringLiteral(CONSTANTS.TYPE_FUNCTION)];
|
|
83
|
-
return t.objectProperty(t.identifier(method.key['name']), t.arrayExpression(elements));
|
|
84
|
-
})
|
|
85
|
-
]), undefined, undefined, undefined, true));
|
|
86
|
-
// attach typings
|
|
87
|
-
visitor(context.fileAST, {
|
|
88
|
-
Program(path) {
|
|
89
|
-
path.node.body.push(Object.assign(t.tsModuleDeclaration(t.identifier('global'), t.tsModuleBlock([
|
|
90
|
-
t.tsInterfaceDeclaration(t.identifier(context.componentInterfaceName), null, [], t.tsInterfaceBody([
|
|
91
|
-
...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
|
|
92
|
-
optional: property.optional,
|
|
93
|
-
leadingComments: property.leadingComments
|
|
94
|
-
}))
|
|
95
|
-
])),
|
|
96
|
-
t.variableDeclaration('var', [
|
|
97
|
-
t.variableDeclarator(Object.assign(t.identifier(context.componentInterfaceName), {
|
|
98
|
-
typeAnnotation: t.tSTypeAnnotation(t.tSTypeLiteral([
|
|
99
|
-
t.tSPropertySignature(t.identifier('prototype'), t.tsTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName)))),
|
|
100
|
-
t.tSConstructSignatureDeclaration(null, [], t.tSTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName))))
|
|
101
|
-
]))
|
|
102
|
-
}))
|
|
103
|
-
]),
|
|
104
|
-
t.tsInterfaceDeclaration(t.identifier('HTMLElementTagNameMap'), null, [], t.tsInterfaceBody([
|
|
105
|
-
t.tSPropertySignature(t.stringLiteral(context.componentTag), t.tSTypeAnnotation(t.tSIntersectionType([t.tSTypeReference(t.identifier(context.componentInterfaceName))])))
|
|
106
|
-
]))
|
|
107
|
-
])), {
|
|
108
|
-
declare: true,
|
|
109
|
-
global: true
|
|
110
|
-
}));
|
|
111
|
-
path.node.body.push(t.exportNamedDeclaration(t.tsInterfaceDeclaration(
|
|
112
|
-
// TODO
|
|
113
|
-
t.identifier(context.componentClassName + 'JSX'), null, [], t.tsInterfaceBody([
|
|
114
|
-
...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
|
|
115
|
-
optional: property.optional,
|
|
116
|
-
leadingComments: property.leadingComments
|
|
117
|
-
})),
|
|
118
|
-
...context.classEvents.map((event) => {
|
|
69
|
+
visitor(ast, {
|
|
70
|
+
ClassDeclaration(path) {
|
|
71
|
+
if (path.node.id.name != context.className)
|
|
72
|
+
return;
|
|
73
|
+
path.node.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_MEMBERS), t.objectExpression([
|
|
74
|
+
...context.classProperties.map((property) => {
|
|
119
75
|
var _a, _b;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
76
|
+
const type = (_b = (_a = property.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation) === null || _b === void 0 ? void 0 : _b.type;
|
|
77
|
+
const elements = [];
|
|
78
|
+
switch (type) {
|
|
79
|
+
case 'TSBooleanKeyword':
|
|
80
|
+
elements.push(t.stringLiteral(CONSTANTS.TYPE_BOOLEAN));
|
|
81
|
+
break;
|
|
82
|
+
case 'TSStringKeyword':
|
|
83
|
+
elements.push(t.stringLiteral(CONSTANTS.TYPE_STRING));
|
|
84
|
+
break;
|
|
85
|
+
case 'TSNumberKeyword':
|
|
86
|
+
elements.push(t.stringLiteral(CONSTANTS.TYPE_NUMBER));
|
|
87
|
+
break;
|
|
88
|
+
default:
|
|
89
|
+
elements.push(t.nullLiteral());
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
if (property.value)
|
|
93
|
+
elements.push(property.value);
|
|
94
|
+
return t.objectProperty(t.identifier(property.key['name']), t.arrayExpression(elements));
|
|
95
|
+
}),
|
|
96
|
+
...context.classMethods.map((method) => {
|
|
97
|
+
const elements = [t.stringLiteral(CONSTANTS.TYPE_FUNCTION)];
|
|
98
|
+
return t.objectProperty(t.identifier(method.key['name']), t.arrayExpression(elements));
|
|
128
99
|
})
|
|
129
|
-
])))
|
|
100
|
+
]), undefined, undefined, undefined, true));
|
|
130
101
|
}
|
|
131
102
|
});
|
|
132
|
-
|
|
103
|
+
// attach typings
|
|
104
|
+
if (options === null || options === void 0 ? void 0 : options.typings) {
|
|
105
|
+
visitor(ast, {
|
|
106
|
+
Program(path) {
|
|
107
|
+
path.node.body.push(Object.assign(t.tsModuleDeclaration(t.identifier('global'), t.tsModuleBlock([
|
|
108
|
+
t.tsInterfaceDeclaration(t.identifier(context.componentInterfaceName), null, [], t.tsInterfaceBody([
|
|
109
|
+
...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
|
|
110
|
+
optional: property.optional,
|
|
111
|
+
leadingComments: property.leadingComments
|
|
112
|
+
}))
|
|
113
|
+
])),
|
|
114
|
+
t.variableDeclaration('var', [
|
|
115
|
+
t.variableDeclarator(Object.assign(t.identifier(context.componentInterfaceName), {
|
|
116
|
+
typeAnnotation: t.tSTypeAnnotation(t.tSTypeLiteral([
|
|
117
|
+
t.tSPropertySignature(t.identifier('prototype'), t.tsTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName)))),
|
|
118
|
+
t.tSConstructSignatureDeclaration(null, [], t.tSTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName))))
|
|
119
|
+
]))
|
|
120
|
+
}))
|
|
121
|
+
]),
|
|
122
|
+
t.tsInterfaceDeclaration(t.identifier('HTMLElementTagNameMap'), null, [], t.tsInterfaceBody([
|
|
123
|
+
t.tSPropertySignature(t.stringLiteral(context.componentTag), t.tSTypeAnnotation(t.tSIntersectionType([t.tSTypeReference(t.identifier(context.componentInterfaceName))])))
|
|
124
|
+
]))
|
|
125
|
+
])), {
|
|
126
|
+
declare: true,
|
|
127
|
+
global: true
|
|
128
|
+
}));
|
|
129
|
+
path.node.body.push(t.exportNamedDeclaration(t.tsInterfaceDeclaration(
|
|
130
|
+
// TODO
|
|
131
|
+
t.identifier(context.componentClassName + 'JSX'), null, [], t.tsInterfaceBody([
|
|
132
|
+
...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
|
|
133
|
+
optional: property.optional,
|
|
134
|
+
leadingComments: property.leadingComments
|
|
135
|
+
})),
|
|
136
|
+
...context.classEvents.map((event) => {
|
|
137
|
+
var _a, _b;
|
|
138
|
+
return Object.assign(t.tSPropertySignature(event.key, t.tsTypeAnnotation(t.tsFunctionType(undefined, [
|
|
139
|
+
Object.assign({}, t.identifier('event'), {
|
|
140
|
+
typeAnnotation: t.tsTypeAnnotation(t.tsTypeReference(t.identifier('CustomEvent'), (_b = (_a = event.typeAnnotation) === null || _a === void 0 ? void 0 : _a['typeAnnotation']) === null || _b === void 0 ? void 0 : _b.typeParameters))
|
|
141
|
+
})
|
|
142
|
+
], t.tsTypeAnnotation(t.tsVoidKeyword())))), {
|
|
143
|
+
optional: true,
|
|
144
|
+
leadingComments: event.leadingComments
|
|
145
|
+
});
|
|
146
|
+
})
|
|
147
|
+
]))));
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
context.script = print(ast);
|
|
133
152
|
};
|
|
134
153
|
return {
|
|
135
154
|
name,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Global } from '../../../types/index.js';
|
|
2
2
|
export interface CustomElementReactOptions {
|
|
3
3
|
compact?: boolean;
|
|
4
|
-
|
|
4
|
+
destination: string;
|
|
5
5
|
eventName?: (eventName: string) => string;
|
|
6
6
|
importerComponent?: (context: any) => string;
|
|
7
7
|
importerComponentType?: (context: any) => string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __dirname, isDirectoryEmpty, renderTemplate } from '../../utils/index.js';
|
|
2
2
|
const defaults = {
|
|
3
3
|
compact: false,
|
|
4
|
-
|
|
4
|
+
destination: '',
|
|
5
5
|
eventName: undefined,
|
|
6
6
|
importerComponent(context) {
|
|
7
7
|
return `YOUR_CORE_PACKAGE_NAME#${context.componentClassName}`;
|
|
@@ -20,7 +20,7 @@ export const customElementReact = (options) => {
|
|
|
20
20
|
options
|
|
21
21
|
};
|
|
22
22
|
const config = { cwd: __dirname(import.meta.url) };
|
|
23
|
-
const isEmpty = isDirectoryEmpty(options.
|
|
23
|
+
const isEmpty = isDirectoryEmpty(options.destination);
|
|
24
24
|
const skip = [];
|
|
25
25
|
const getKey = (component) => component.componentClassName;
|
|
26
26
|
for (const key in globalNew.contexts) {
|
|
@@ -52,7 +52,7 @@ export const customElementReact = (options) => {
|
|
|
52
52
|
'templates/src/components/*fileName*.ts.hbs',
|
|
53
53
|
'!templates/src/components/*fileName*.compact.ts.hbs'
|
|
54
54
|
];
|
|
55
|
-
renderTemplate(patterns, options.
|
|
55
|
+
renderTemplate(patterns, options.destination, config)(state);
|
|
56
56
|
}
|
|
57
57
|
if (options.compact) {
|
|
58
58
|
globalNew.groups = Object.values(globalNew.contexts)
|
|
@@ -69,7 +69,9 @@ export const customElementReact = (options) => {
|
|
|
69
69
|
return true;
|
|
70
70
|
})
|
|
71
71
|
.map((group) => {
|
|
72
|
-
const all = group.components
|
|
72
|
+
const all = group.components
|
|
73
|
+
.reverse()
|
|
74
|
+
.map((component, index) => {
|
|
73
75
|
const componentClassNameInCategory = getKey(component).replace(group.key, '');
|
|
74
76
|
const parse = (input) => {
|
|
75
77
|
const [source, key] = input.split('#');
|
|
@@ -88,7 +90,9 @@ export const customElementReact = (options) => {
|
|
|
88
90
|
return Object.assign(Object.assign({}, component), { componentClassNameInCategory,
|
|
89
91
|
importerComponent,
|
|
90
92
|
importerComponentType });
|
|
91
|
-
})
|
|
93
|
+
})
|
|
94
|
+
// TODO: experimental
|
|
95
|
+
.sort((a, b) => (b.componentClassName < a.componentClassName ? 0 : -1));
|
|
92
96
|
return {
|
|
93
97
|
all,
|
|
94
98
|
filterd: all.slice(1),
|
|
@@ -102,7 +106,7 @@ export const customElementReact = (options) => {
|
|
|
102
106
|
continue;
|
|
103
107
|
const state = Object.assign({ fileName: group.root.fileName, options }, group);
|
|
104
108
|
const patterns = ['templates/src/components/*fileName*.compact.ts.hbs'];
|
|
105
|
-
renderTemplate(patterns, options.
|
|
109
|
+
renderTemplate(patterns, options.destination, config)(state);
|
|
106
110
|
}
|
|
107
111
|
}
|
|
108
112
|
if (isEmpty) {
|
|
@@ -111,11 +115,11 @@ export const customElementReact = (options) => {
|
|
|
111
115
|
'!templates/src/components/*fileName*.ts.hbs',
|
|
112
116
|
'!templates/src/components/*fileName*.compact.ts.hbs'
|
|
113
117
|
];
|
|
114
|
-
renderTemplate(patterns, options.
|
|
118
|
+
renderTemplate(patterns, options.destination, config)(globalNew);
|
|
115
119
|
}
|
|
116
120
|
if (!isEmpty) {
|
|
117
121
|
const patterns = ['templates/src/proxy*', 'templates/src/components/index*'];
|
|
118
|
-
renderTemplate(patterns, options.
|
|
122
|
+
renderTemplate(patterns, options.destination, config)(globalNew);
|
|
119
123
|
}
|
|
120
124
|
};
|
|
121
125
|
return {
|
package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
**************************************************/
|
|
7
7
|
|
|
8
8
|
{{#each all}}
|
|
9
|
-
import { {{
|
|
9
|
+
import { {{componentClassNamePrune}} } from './{{fileName}}';
|
|
10
10
|
{{/each}}
|
|
11
11
|
|
|
12
|
-
const All = /*@__PURE__*/ Object.assign({{root.
|
|
12
|
+
const All = /*@__PURE__*/ Object.assign({{root.componentClassNamePrune}}, {
|
|
13
13
|
{{#each filterd}}
|
|
14
|
-
{{componentClassNameInCategory}}: {{
|
|
14
|
+
{{componentClassNameInCategory}}: {{componentClassNamePrune}},
|
|
15
15
|
{{/each}}
|
|
16
16
|
});
|
|
17
17
|
|
|
18
|
-
export { All as {{root.
|
|
18
|
+
export { All as {{root.componentClassNamePrune}} }
|
|
@@ -19,7 +19,7 @@ type Renamed = Rename<{{importerComponentType.variable}}, {
|
|
|
19
19
|
{{/each}}
|
|
20
20
|
}>
|
|
21
21
|
|
|
22
|
-
export const {{
|
|
22
|
+
export const {{componentClassNamePrune}} = /*@__PURE__*/ proxy<{{componentInterfaceName}}, Renamed>(
|
|
23
23
|
'{{componentTag}}',
|
|
24
24
|
[{{#each classProperties}}'{{key.name}}', {{/each}}],
|
|
25
25
|
[{{#each classEvents}}'{{key.name}}', {{/each}}],
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Context } from '../../types/index.js';
|
|
2
|
-
export interface
|
|
3
|
-
|
|
4
|
-
prefix: string;
|
|
2
|
+
export interface DocumentOptions {
|
|
3
|
+
destination: string;
|
|
5
4
|
}
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const document: (options: DocumentOptions) => {
|
|
7
6
|
name: string;
|
|
8
7
|
start: (global: any) => void;
|
|
9
8
|
next: (context: Context, global: any) => void;
|