@htmlplus/element 0.3.0 → 0.3.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 +4 -4
- package/package.json +8 -45
- package/dist/client/decorators/attributes.d.ts +0 -2
- package/dist/client/decorators/attributes.js +0 -13
- package/dist/client/decorators/bind.d.ts +0 -4
- package/dist/client/decorators/bind.js +0 -17
- package/dist/client/decorators/element.d.ts +0 -2
- package/dist/client/decorators/element.js +0 -49
- package/dist/client/decorators/event.d.ts +0 -21
- package/dist/client/decorators/event.js +0 -18
- package/dist/client/decorators/index.d.ts +0 -9
- package/dist/client/decorators/index.js +0 -9
- package/dist/client/decorators/listen.d.ts +0 -12
- package/dist/client/decorators/listen.js +0 -30
- package/dist/client/decorators/method.d.ts +0 -2
- package/dist/client/decorators/method.js +0 -12
- package/dist/client/decorators/property.d.ts +0 -12
- package/dist/client/decorators/property.js +0 -51
- package/dist/client/decorators/state.d.ts +0 -2
- package/dist/client/decorators/state.js +0 -32
- package/dist/client/decorators/watch.d.ts +0 -2
- package/dist/client/decorators/watch.js +0 -17
- package/dist/client/helpers/classes.d.ts +0 -1
- package/dist/client/helpers/classes.js +0 -62
- package/dist/client/helpers/direction.d.ts +0 -3
- package/dist/client/helpers/direction.js +0 -4
- package/dist/client/helpers/index.d.ts +0 -9
- package/dist/client/helpers/index.js +0 -9
- package/dist/client/helpers/is-rtl.d.ts +0 -2
- package/dist/client/helpers/is-rtl.js +0 -2
- package/dist/client/helpers/query-all.d.ts +0 -3
- package/dist/client/helpers/query-all.js +0 -5
- package/dist/client/helpers/query.d.ts +0 -3
- package/dist/client/helpers/query.js +0 -5
- package/dist/client/helpers/slots.d.ts +0 -6
- package/dist/client/helpers/slots.js +0 -15
- package/dist/client/helpers/styles.d.ts +0 -1
- package/dist/client/helpers/styles.js +0 -16
- package/dist/client/helpers/to-unit.d.ts +0 -1
- package/dist/client/helpers/to-unit.js +0 -7
- package/dist/client/index.d.ts +0 -3
- package/dist/client/index.js +0 -3
- package/dist/client/services/index.d.ts +0 -1
- package/dist/client/services/index.js +0 -1
- package/dist/client/services/link.d.ts +0 -4
- package/dist/client/services/link.js +0 -196
- package/dist/client/utils/append-to-method.d.ts +0 -2
- package/dist/client/utils/append-to-method.js +0 -7
- package/dist/client/utils/call.d.ts +0 -2
- package/dist/client/utils/call.js +0 -4
- package/dist/client/utils/define-property.d.ts +0 -1
- package/dist/client/utils/define-property.js +0 -1
- package/dist/client/utils/event.d.ts +0 -2
- package/dist/client/utils/event.js +0 -6
- package/dist/client/utils/get-members.d.ts +0 -2
- package/dist/client/utils/get-members.js +0 -5
- package/dist/client/utils/get-styles.d.ts +0 -2
- package/dist/client/utils/get-styles.js +0 -5
- package/dist/client/utils/host.d.ts +0 -2
- package/dist/client/utils/host.js +0 -4
- package/dist/client/utils/index.d.ts +0 -20
- package/dist/client/utils/index.js +0 -20
- package/dist/client/utils/is-event.d.ts +0 -1
- package/dist/client/utils/is-event.js +0 -3
- package/dist/client/utils/is-ready.d.ts +0 -2
- package/dist/client/utils/is-ready.js +0 -4
- package/dist/client/utils/is-server.d.ts +0 -1
- package/dist/client/utils/is-server.js +0 -3
- package/dist/client/utils/on-ready.d.ts +0 -2
- package/dist/client/utils/on-ready.js +0 -6
- package/dist/client/utils/parse-value.d.ts +0 -1
- package/dist/client/utils/parse-value.js +0 -15
- package/dist/client/utils/render.d.ts +0 -2
- package/dist/client/utils/render.js +0 -19
- package/dist/client/utils/request.d.ts +0 -2
- package/dist/client/utils/request.js +0 -28
- package/dist/client/utils/sync.d.ts +0 -1
- package/dist/client/utils/sync.js +0 -31
- package/dist/client/utils/task.d.ts +0 -6
- package/dist/client/utils/task.js +0 -37
- package/dist/client/utils/to-boolean.d.ts +0 -1
- package/dist/client/utils/to-boolean.js +0 -3
- package/dist/client/utils/to-event.d.ts +0 -1
- package/dist/client/utils/to-event.js +0 -3
- package/dist/client/utils/type-of.d.ts +0 -3
- package/dist/client/utils/type-of.js +0 -6
- package/dist/client/utils/update-attribute.d.ts +0 -1
- package/dist/client/utils/update-attribute.js +0 -7
- package/dist/compiler/compiler.d.ts +0 -7
- package/dist/compiler/compiler.js +0 -55
- package/dist/compiler/index.d.ts +0 -2
- package/dist/compiler/index.js +0 -2
- package/dist/compiler/plugins/componentDependencyResolver.d.ts +0 -5
- package/dist/compiler/plugins/componentDependencyResolver.js +0 -40
- package/dist/compiler/plugins/customElement.d.ts +0 -5
- package/dist/compiler/plugins/customElement.js +0 -138
- package/dist/compiler/plugins/customElementReact/customElementReact.d.ts +0 -12
- package/dist/compiler/plugins/customElementReact/customElementReact.js +0 -125
- package/dist/compiler/plugins/customElementReact/index.d.ts +0 -1
- package/dist/compiler/plugins/customElementReact/index.js +0 -1
- package/dist/compiler/plugins/customElementReact/templates/README.md.hbs +0 -1
- package/dist/compiler/plugins/customElementReact/templates/_.gitignore.hbs +0 -2
- package/dist/compiler/plugins/customElementReact/templates/package.json.hbs +0 -37
- package/dist/compiler/plugins/customElementReact/templates/rollup.config.js.hbs +0 -21
- package/dist/compiler/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -17
- package/dist/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +0 -18
- package/dist/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +0 -26
- package/dist/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
- package/dist/compiler/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -278
- package/dist/compiler/plugins/customElementReact/templates/tsconfig.json.hbs +0 -17
- package/dist/compiler/plugins/docs.d.ts +0 -11
- package/dist/compiler/plugins/docs.js +0 -320
- package/dist/compiler/plugins/extract.d.ts +0 -8
- package/dist/compiler/plugins/extract.js +0 -70
- package/dist/compiler/plugins/index.d.ts +0 -7
- package/dist/compiler/plugins/index.js +0 -7
- package/dist/compiler/plugins/parse.d.ts +0 -5
- package/dist/compiler/plugins/parse.js +0 -16
- package/dist/compiler/plugins/read.d.ts +0 -5
- package/dist/compiler/plugins/read.js +0 -13
- package/dist/compiler/plugins/style.d.ts +0 -12
- package/dist/compiler/plugins/style.js +0 -42
- package/dist/compiler/plugins/validate.d.ts +0 -5
- package/dist/compiler/plugins/validate.js +0 -40
- package/dist/compiler/plugins/vscode.d.ts +0 -11
- package/dist/compiler/plugins/vscode.js +0 -83
- package/dist/compiler/utils/__dirname.d.ts +0 -1
- package/dist/compiler/utils/__dirname.js +0 -5
- package/dist/compiler/utils/get-initializer.d.ts +0 -2
- package/dist/compiler/utils/get-initializer.js +0 -10
- package/dist/compiler/utils/get-tags.d.ts +0 -6
- package/dist/compiler/utils/get-tags.js +0 -34
- package/dist/compiler/utils/get-type.d.ts +0 -2
- package/dist/compiler/utils/get-type.js +0 -69
- package/dist/compiler/utils/has-decorator.d.ts +0 -1
- package/dist/compiler/utils/has-decorator.js +0 -5
- package/dist/compiler/utils/index.d.ts +0 -10
- package/dist/compiler/utils/index.js +0 -10
- package/dist/compiler/utils/is-directory-empty.d.ts +0 -1
- package/dist/compiler/utils/is-directory-empty.js +0 -10
- package/dist/compiler/utils/print-type.d.ts +0 -1
- package/dist/compiler/utils/print-type.js +0 -69
- package/dist/compiler/utils/print.d.ts +0 -2
- package/dist/compiler/utils/print.js +0 -5
- package/dist/compiler/utils/render-template.d.ts +0 -1
- package/dist/compiler/utils/render-template.js +0 -25
- package/dist/compiler/utils/visitor.d.ts +0 -2
- package/dist/compiler/utils/visitor.js +0 -5
- package/dist/constants/index.d.ts +0 -23
- package/dist/constants/index.js +0 -29
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.js +0 -4
- package/dist/types/context.d.ts +0 -32
- package/dist/types/context.js +0 -1
- package/dist/types/global.d.ts +0 -4
- package/dist/types/global.js +0 -1
- package/dist/types/index.d.ts +0 -4
- package/dist/types/index.js +0 -4
- package/dist/types/plugin.d.ts +0 -9
- package/dist/types/plugin.js +0 -1
- package/dist/types/plus-element.d.ts +0 -2
- package/dist/types/plus-element.js +0 -1
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { visitor } from '../utils/index.js';
|
|
2
|
-
export const componentDependencyResolver = () => {
|
|
3
|
-
const name = 'componentDependencyResolver';
|
|
4
|
-
const next = (context, global) => {
|
|
5
|
-
var _a, _b, _c, _d;
|
|
6
|
-
if (!context.dependenciesUnresolved) {
|
|
7
|
-
visitor(context.fileAST, {
|
|
8
|
-
JSXOpeningElement(path) {
|
|
9
|
-
var _a, _b, _c;
|
|
10
|
-
const name = path.node.name.name;
|
|
11
|
-
if (!name.includes('-'))
|
|
12
|
-
return;
|
|
13
|
-
const find = (_a = context.dependenciesUnresolved) === null || _a === void 0 ? void 0 : _a.includes(name);
|
|
14
|
-
if (find)
|
|
15
|
-
return;
|
|
16
|
-
(_b = context.dependenciesUnresolved) !== null && _b !== void 0 ? _b : (context.dependenciesUnresolved = []);
|
|
17
|
-
(_c = context.dependenciesUnresolved) === null || _c === void 0 ? void 0 : _c.push(name);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
for (const current of global.contexts) {
|
|
22
|
-
if (!((_a = current.dependenciesUnresolved) === null || _a === void 0 ? void 0 : _a.length))
|
|
23
|
-
continue;
|
|
24
|
-
const dependencies = global.contexts.filter((context) => { var _a; return (_a = current.dependenciesUnresolved) === null || _a === void 0 ? void 0 : _a.includes(context.componentTag); });
|
|
25
|
-
for (const dependency of dependencies) {
|
|
26
|
-
if ((_b = current.dependencies) === null || _b === void 0 ? void 0 : _b.some((item) => item.componentTag == dependency.componentTag))
|
|
27
|
-
continue;
|
|
28
|
-
(_c = current.dependencies) !== null && _c !== void 0 ? _c : (current.dependencies = []);
|
|
29
|
-
current.dependencies.push(dependency);
|
|
30
|
-
current.dependenciesUnresolved = (_d = current.dependenciesUnresolved) === null || _d === void 0 ? void 0 : _d.filter((current) => current != dependency.componentTag);
|
|
31
|
-
// TODO
|
|
32
|
-
// current.fileAST!.program.body.unshift(t.importDeclaration([], t.stringLiteral(dependency.filePath!)));
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
return {
|
|
37
|
-
name,
|
|
38
|
-
next
|
|
39
|
-
};
|
|
40
|
-
};
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import t from '@babel/types';
|
|
2
|
-
import * as CONSTANTS from '../../constants/index.js';
|
|
3
|
-
import { print, visitor } from '../utils/index.js';
|
|
4
|
-
export const customElement = () => {
|
|
5
|
-
const name = 'customElement';
|
|
6
|
-
const next = (context) => {
|
|
7
|
-
// attach uhtml importer
|
|
8
|
-
context.fileAST.program.body.unshift(t.importDeclaration([t.importSpecifier(t.identifier('html'), t.identifier('html'))], t.stringLiteral('@htmlplus/element/runtime')));
|
|
9
|
-
// jsx to uhtml syntax
|
|
10
|
-
visitor(context.fileAST, {
|
|
11
|
-
JSXAttribute: {
|
|
12
|
-
exit(path) {
|
|
13
|
-
var _a;
|
|
14
|
-
if (((_a = path.node.value) === null || _a === void 0 ? void 0 : _a.type) == 'JSXExpressionContainer') {
|
|
15
|
-
let node = path.node;
|
|
16
|
-
if (path.node.name.name == 'ref') {
|
|
17
|
-
node = t.jsxAttribute(path.node.name, t.jSXExpressionContainer(t.arrowFunctionExpression([t.identifier('$element')], t.assignmentExpression('=', path.node.value.expression, t.identifier('$element')))));
|
|
18
|
-
}
|
|
19
|
-
path.replaceWith(t.jsxIdentifier(print(node).replace('={', '=${')));
|
|
20
|
-
path.skip();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
JSXElement: {
|
|
26
|
-
exit(path) {
|
|
27
|
-
if (path.parent.type == 'JSXElement' || path.parent.type == 'JSXFragment') {
|
|
28
|
-
path.replaceWith(t.identifier(print(path.node)));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
path.replaceWith(t.identifier('html`' + print(path.node) + '`'));
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
JSXFragment: {
|
|
38
|
-
exit(path) {
|
|
39
|
-
path.replaceWith(t.identifier(['html`', ...path.node.children.map((child) => print(child)), '`'].join('')));
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
JSXExpressionContainer: {
|
|
43
|
-
exit(path) {
|
|
44
|
-
if (path.parent.type == 'JSXElement' || path.parent.type == 'JSXFragment') {
|
|
45
|
-
path.replaceWith(t.identifier('$' + print(path.node)));
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
JSXSpreadAttribute: {
|
|
51
|
-
enter(path) {
|
|
52
|
-
// TODO
|
|
53
|
-
path.replaceWith(t.jsxAttribute(t.jsxIdentifier('.dataset'), t.jsxExpressionContainer(path.node.argument)));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
// attach members
|
|
58
|
-
context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_MEMBERS), t.objectExpression([
|
|
59
|
-
...context.classProperties.map((property) => {
|
|
60
|
-
var _a, _b;
|
|
61
|
-
const type = (_b = (_a = property.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation) === null || _b === void 0 ? void 0 : _b.type;
|
|
62
|
-
const elements = [];
|
|
63
|
-
switch (type) {
|
|
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) => {
|
|
119
|
-
var _a, _b;
|
|
120
|
-
return Object.assign(t.tSPropertySignature(event.key, t.tsTypeAnnotation(t.tsFunctionType(undefined, [
|
|
121
|
-
Object.assign({}, t.identifier('event'), {
|
|
122
|
-
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))
|
|
123
|
-
})
|
|
124
|
-
], t.tsTypeAnnotation(t.tsVoidKeyword())))), {
|
|
125
|
-
optional: true,
|
|
126
|
-
leadingComments: event.leadingComments
|
|
127
|
-
});
|
|
128
|
-
})
|
|
129
|
-
]))));
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
context.script = print(context.fileAST);
|
|
133
|
-
};
|
|
134
|
-
return {
|
|
135
|
-
name,
|
|
136
|
-
next
|
|
137
|
-
};
|
|
138
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Global } from '../../../types/index.js';
|
|
2
|
-
export interface CustomElementReactOptions {
|
|
3
|
-
compact?: boolean;
|
|
4
|
-
dist: string;
|
|
5
|
-
eventName?: (eventName: string) => string;
|
|
6
|
-
importerComponent?: (context: any) => string;
|
|
7
|
-
importerComponentType?: (context: any) => string;
|
|
8
|
-
}
|
|
9
|
-
export declare const customElementReact: (options: CustomElementReactOptions) => {
|
|
10
|
-
name: string;
|
|
11
|
-
finish: (global: Global) => void;
|
|
12
|
-
};
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { __dirname, isDirectoryEmpty, renderTemplate } from '../../utils/index.js';
|
|
2
|
-
const defaults = {
|
|
3
|
-
compact: false,
|
|
4
|
-
dist: '',
|
|
5
|
-
eventName: undefined,
|
|
6
|
-
importerComponent(context) {
|
|
7
|
-
return `YOUR_CORE_PACKAGE_NAME#${context.componentClassName}`;
|
|
8
|
-
},
|
|
9
|
-
importerComponentType(context) {
|
|
10
|
-
return `YOUR_CORE_PACKAGE_NAME#JSX.${context.componentClassName}`;
|
|
11
|
-
}
|
|
12
|
-
};
|
|
13
|
-
export const customElementReact = (options) => {
|
|
14
|
-
const name = 'customElementReact';
|
|
15
|
-
const finish = (global) => {
|
|
16
|
-
options = Object.assign(Object.assign({}, defaults), options);
|
|
17
|
-
// TODO
|
|
18
|
-
const globalNew = {
|
|
19
|
-
contexts: global.contexts.reduce((previous, current) => (Object.assign(Object.assign({}, previous), { [current.filePath]: current })), {}),
|
|
20
|
-
options
|
|
21
|
-
};
|
|
22
|
-
const config = { cwd: __dirname(import.meta.url) };
|
|
23
|
-
const isEmpty = isDirectoryEmpty(options.dist);
|
|
24
|
-
const skip = [];
|
|
25
|
-
const getKey = (component) => component.componentClassName;
|
|
26
|
-
for (const key in globalNew.contexts) {
|
|
27
|
-
const context = globalNew.contexts[key];
|
|
28
|
-
const parse = (input) => {
|
|
29
|
-
const [source, key] = input.split('#');
|
|
30
|
-
const [root, ...sub] = key.split('.');
|
|
31
|
-
const variable = ['Type', ...sub].join('.');
|
|
32
|
-
return {
|
|
33
|
-
source,
|
|
34
|
-
variable,
|
|
35
|
-
root
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const classEvents = context.classEvents.map((classEvent) => {
|
|
39
|
-
var _a;
|
|
40
|
-
const name = ((_a = options.eventName) === null || _a === void 0 ? void 0 : _a.call(options, classEvent.key.name)) || classEvent.key.name;
|
|
41
|
-
return Object.assign(Object.assign({}, classEvent), { converted: 'on' + name.charAt(0).toUpperCase() + name.slice(1) });
|
|
42
|
-
});
|
|
43
|
-
const fileName = context.fileName;
|
|
44
|
-
const importerComponent = parse(options.importerComponent(context));
|
|
45
|
-
const importerComponentType = parse(options.importerComponentType(context));
|
|
46
|
-
const state = Object.assign(Object.assign({}, context), { classEvents,
|
|
47
|
-
fileName,
|
|
48
|
-
importerComponent,
|
|
49
|
-
importerComponentType,
|
|
50
|
-
options });
|
|
51
|
-
const patterns = [
|
|
52
|
-
'templates/src/components/*fileName*.ts.hbs',
|
|
53
|
-
'!templates/src/components/*fileName*.compact.ts.hbs'
|
|
54
|
-
];
|
|
55
|
-
renderTemplate(patterns, options.dist, config)(state);
|
|
56
|
-
}
|
|
57
|
-
if (options.compact) {
|
|
58
|
-
globalNew.groups = Object.values(globalNew.contexts)
|
|
59
|
-
.sort((a, b) => getKey(b).length - getKey(a).length)
|
|
60
|
-
.map((component, index, components) => ({
|
|
61
|
-
key: getKey(component),
|
|
62
|
-
components: components.filter((current) => getKey(current).startsWith(getKey(component)))
|
|
63
|
-
}))
|
|
64
|
-
.sort((a, b) => b.components.length - a.components.length)
|
|
65
|
-
.filter((group) => {
|
|
66
|
-
if (skip.includes(group.key))
|
|
67
|
-
return;
|
|
68
|
-
group.components.forEach((component) => skip.push(getKey(component)));
|
|
69
|
-
return true;
|
|
70
|
-
})
|
|
71
|
-
.map((group) => {
|
|
72
|
-
const all = group.components.reverse().map((component, index) => {
|
|
73
|
-
const componentClassNameInCategory = getKey(component).replace(group.key, '');
|
|
74
|
-
const parse = (input) => {
|
|
75
|
-
const [source, key] = input.split('#');
|
|
76
|
-
const [root, ...sub] = key.split('.');
|
|
77
|
-
const local = root + (index + 1);
|
|
78
|
-
const variable = [local, ...sub].join('.');
|
|
79
|
-
return {
|
|
80
|
-
source,
|
|
81
|
-
variable,
|
|
82
|
-
root,
|
|
83
|
-
local
|
|
84
|
-
};
|
|
85
|
-
};
|
|
86
|
-
const importerComponent = parse(options.importerComponent(component));
|
|
87
|
-
const importerComponentType = parse(options.importerComponentType(component));
|
|
88
|
-
return Object.assign(Object.assign({}, component), { componentClassNameInCategory,
|
|
89
|
-
importerComponent,
|
|
90
|
-
importerComponentType });
|
|
91
|
-
});
|
|
92
|
-
return {
|
|
93
|
-
all,
|
|
94
|
-
filterd: all.slice(1),
|
|
95
|
-
root: all.at(0),
|
|
96
|
-
single: all.length == 1
|
|
97
|
-
};
|
|
98
|
-
})
|
|
99
|
-
.sort((a, b) => (getKey(a.root) < getKey(b.root) ? -1 : 0));
|
|
100
|
-
for (const group of globalNew.groups) {
|
|
101
|
-
if (group.single)
|
|
102
|
-
continue;
|
|
103
|
-
const state = Object.assign({ fileName: group.root.fileName, options }, group);
|
|
104
|
-
const patterns = ['templates/src/components/*fileName*.compact.ts.hbs'];
|
|
105
|
-
renderTemplate(patterns, options.dist, config)(state);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
if (isEmpty) {
|
|
109
|
-
const patterns = [
|
|
110
|
-
'templates/**',
|
|
111
|
-
'!templates/src/components/*fileName*.ts.hbs',
|
|
112
|
-
'!templates/src/components/*fileName*.compact.ts.hbs'
|
|
113
|
-
];
|
|
114
|
-
renderTemplate(patterns, options.dist, config)(globalNew);
|
|
115
|
-
}
|
|
116
|
-
if (!isEmpty) {
|
|
117
|
-
const patterns = ['templates/src/proxy*', 'templates/src/components/index*'];
|
|
118
|
-
renderTemplate(patterns, options.dist, config)(globalNew);
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
return {
|
|
122
|
-
name,
|
|
123
|
-
finish
|
|
124
|
-
};
|
|
125
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './customElementReact.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './customElementReact.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# React output target for your custom element.
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "YOUR_REACT_PACKAGE_NAME",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"type": "module",
|
|
5
|
-
"description": "React output target for your custom element.",
|
|
6
|
-
"exports": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"scripts": {
|
|
9
|
-
"prebuild": "npm run clean",
|
|
10
|
-
"build": "rollup -c",
|
|
11
|
-
"clean": "rimraf dist"
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
"dist"
|
|
15
|
-
],
|
|
16
|
-
"dependencies": {
|
|
17
|
-
"YOUR_CORE_PACKAGE_NAME": "latest",
|
|
18
|
-
"change-case": "^4.1.2"
|
|
19
|
-
},
|
|
20
|
-
"devDependencies": {
|
|
21
|
-
"@rollup/plugin-commonjs": "^15.0.0",
|
|
22
|
-
"@rollup/plugin-node-resolve": "^9.0.0",
|
|
23
|
-
"@types/react": "^16.9.49",
|
|
24
|
-
"glob": "^7.2.0",
|
|
25
|
-
"react": "^17.0.1",
|
|
26
|
-
"react-dom": "^17.0.1",
|
|
27
|
-
"rimraf": "^3.0.2",
|
|
28
|
-
"rollup": "^2.27.1",
|
|
29
|
-
"rollup-plugin-peer-deps-external": "^2.2.3",
|
|
30
|
-
"rollup-plugin-typescript2": "^0.27.2",
|
|
31
|
-
"typescript": "^4.0.2"
|
|
32
|
-
},
|
|
33
|
-
"peerDependencies": {
|
|
34
|
-
"react": "^16.0.0 || ^17.0.0",
|
|
35
|
-
"react-dom": "^16.0.0 || ^17.0.0"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import commonjs from '@rollup/plugin-commonjs';
|
|
2
|
-
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
-
import glob from 'glob';
|
|
4
|
-
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
5
|
-
import typescript from 'rollup-plugin-typescript2';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
input: glob.sync('src/**/*.ts'),
|
|
9
|
-
output: [
|
|
10
|
-
{
|
|
11
|
-
dir: 'dist',
|
|
12
|
-
format: 'esm',
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
plugins: [
|
|
16
|
-
peerDepsExternal(),
|
|
17
|
-
resolve(),
|
|
18
|
-
commonjs(),
|
|
19
|
-
typescript(),
|
|
20
|
-
],
|
|
21
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**************************************************
|
|
2
|
-
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT MANUALY
|
|
3
|
-
**************************************************/
|
|
4
|
-
|
|
5
|
-
{{#if options.compact}}
|
|
6
|
-
{{#each groups}}
|
|
7
|
-
{{#if single}}
|
|
8
|
-
export * from './{{root.fileName}}';
|
|
9
|
-
{{else}}
|
|
10
|
-
export * from './{{root.fileName}}.compact';
|
|
11
|
-
{{/if}}
|
|
12
|
-
{{/each}}
|
|
13
|
-
{{else}}
|
|
14
|
-
{{#each contexts}}
|
|
15
|
-
export * from './{{fileName}}';
|
|
16
|
-
{{/each}}
|
|
17
|
-
{{/if}}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
|
|
4
|
-
/**************************************************
|
|
5
|
-
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT MANUALY
|
|
6
|
-
**************************************************/
|
|
7
|
-
|
|
8
|
-
{{#each all}}
|
|
9
|
-
import { {{componentClassName}} } from './{{fileName}}';
|
|
10
|
-
{{/each}}
|
|
11
|
-
|
|
12
|
-
const All = /*@__PURE__*/ Object.assign({{root.componentClassName}}, {
|
|
13
|
-
{{#each filterd}}
|
|
14
|
-
{{componentClassNameInCategory}}: {{componentClassName}},
|
|
15
|
-
{{/each}}
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
export { All as {{root.componentClassName}} }
|
package/dist/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/* tslint:disable */
|
|
3
|
-
|
|
4
|
-
/**************************************************
|
|
5
|
-
* THIS FILE IS AUTO-GENERATED, DO NOT EDIT MANUALY
|
|
6
|
-
**************************************************/
|
|
7
|
-
|
|
8
|
-
import { proxy } from '../proxy';
|
|
9
|
-
|
|
10
|
-
{{!-- import { {{importerComponent.root}} as Component } from '{{importerComponent.source}}'; --}}
|
|
11
|
-
import '{{importerComponent.source}}';
|
|
12
|
-
import type { {{importerComponentType.root}} as Type } from '{{importerComponentType.source}}';
|
|
13
|
-
|
|
14
|
-
type Rename<T, R extends { [K in keyof R]: K extends keyof T ? PropertyKey : "Error: key not in T" }> = { [P in keyof T as P extends keyof R ? R[P] : P]: T[P] }
|
|
15
|
-
|
|
16
|
-
type Renamed = Rename<{{importerComponentType.variable}}, {
|
|
17
|
-
{{#each classEvents}}
|
|
18
|
-
{{key.name}}: '{{converted}}',
|
|
19
|
-
{{/each}}
|
|
20
|
-
}>
|
|
21
|
-
|
|
22
|
-
export const {{componentClassName}} = /*@__PURE__*/ proxy<{{componentInterfaceName}}, Renamed>(
|
|
23
|
-
'{{componentTag}}',
|
|
24
|
-
[{{#each classProperties}}'{{key.name}}', {{/each}}],
|
|
25
|
-
[{{#each classEvents}}'{{key.name}}', {{/each}}],
|
|
26
|
-
);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './components';
|