@htmlplus/element 0.2.0 → 0.3.2
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 +34 -4
- package/{dist/client → client}/decorators/attributes.d.ts +0 -0
- package/{dist/client → client}/decorators/attributes.js +1 -1
- package/{dist/client → client}/decorators/bind.d.ts +0 -0
- package/{dist/client → client}/decorators/bind.js +0 -0
- package/{dist/client → client}/decorators/element.d.ts +0 -0
- package/{dist/client → client}/decorators/element.js +1 -1
- package/{dist/client → client}/decorators/event.d.ts +0 -0
- package/{dist/client → client}/decorators/event.js +0 -0
- package/{dist/client → client}/decorators/index.d.ts +0 -0
- package/{dist/client → client}/decorators/index.js +0 -0
- package/{dist/client → client}/decorators/listen.d.ts +0 -0
- package/{dist/client → client}/decorators/listen.js +1 -1
- package/{dist/client → client}/decorators/method.d.ts +0 -0
- package/{dist/client → client}/decorators/method.js +0 -0
- package/{dist/client → client}/decorators/property.d.ts +0 -0
- package/{dist/client → client}/decorators/property.js +0 -0
- package/{dist/client → client}/decorators/state.d.ts +0 -0
- package/{dist/client → client}/decorators/state.js +0 -0
- package/{dist/client → client}/decorators/watch.d.ts +0 -0
- package/{dist/client → client}/decorators/watch.js +1 -1
- package/{dist/client → client}/helpers/classes.d.ts +0 -0
- package/{dist/client → client}/helpers/classes.js +0 -0
- package/{dist/client → client}/helpers/direction.d.ts +0 -0
- package/{dist/client → client}/helpers/direction.js +0 -0
- package/{dist/client → client}/helpers/index.d.ts +0 -0
- package/{dist/client → client}/helpers/index.js +0 -0
- package/{dist/client → client}/helpers/is-rtl.d.ts +0 -0
- package/{dist/client → client}/helpers/is-rtl.js +0 -0
- package/{dist/client → client}/helpers/query-all.d.ts +0 -0
- package/{dist/client → client}/helpers/query-all.js +0 -0
- package/{dist/client → client}/helpers/query.d.ts +0 -0
- package/{dist/client → client}/helpers/query.js +0 -0
- package/{dist/client → client}/helpers/slots.d.ts +0 -0
- package/{dist/client → client}/helpers/slots.js +0 -0
- package/{dist/client → client}/helpers/styles.d.ts +0 -0
- package/{dist/client → client}/helpers/styles.js +0 -0
- package/{dist/client → client}/helpers/to-unit.d.ts +0 -0
- package/{dist/client → client}/helpers/to-unit.js +0 -0
- package/{dist/client → client}/index.d.ts +0 -0
- package/{dist/client → client}/index.js +0 -0
- package/{dist/client → client}/services/index.d.ts +0 -0
- package/{dist/client → client}/services/index.js +0 -0
- package/{dist/client → client}/services/link.d.ts +0 -0
- package/{dist/client → client}/services/link.js +0 -0
- package/{dist/client → client}/utils/append-to-method.d.ts +0 -0
- package/{dist/client → client}/utils/append-to-method.js +0 -0
- package/{dist/client → client}/utils/call.d.ts +0 -0
- package/{dist/client → client}/utils/call.js +0 -0
- package/{dist/client → client}/utils/define-property.d.ts +0 -0
- package/{dist/client → client}/utils/define-property.js +0 -0
- package/{dist/client → client}/utils/event.d.ts +0 -0
- package/{dist/client → client}/utils/event.js +0 -0
- package/{dist/client → client}/utils/get-members.d.ts +0 -0
- package/{dist/client → client}/utils/get-members.js +1 -1
- package/{dist/client → client}/utils/get-styles.d.ts +0 -0
- package/{dist/client → client}/utils/get-styles.js +1 -1
- package/{dist/client → client}/utils/host.d.ts +0 -0
- package/{dist/client → client}/utils/host.js +1 -1
- package/{dist/client → client}/utils/index.d.ts +0 -0
- package/{dist/client → client}/utils/index.js +0 -0
- package/{dist/client → client}/utils/is-event.d.ts +0 -0
- package/{dist/client → client}/utils/is-event.js +0 -0
- package/{dist/client → client}/utils/is-ready.d.ts +0 -0
- package/{dist/client → client}/utils/is-ready.js +1 -1
- package/{dist/client → client}/utils/is-server.d.ts +0 -0
- package/{dist/client → client}/utils/is-server.js +0 -0
- package/{dist/client → client}/utils/on-ready.d.ts +0 -0
- package/{dist/client → client}/utils/on-ready.js +1 -1
- package/{dist/client → client}/utils/parse-value.d.ts +0 -0
- package/{dist/client → client}/utils/parse-value.js +1 -1
- package/{dist/client → client}/utils/render.d.ts +0 -0
- package/{dist/client → client}/utils/render.js +1 -1
- package/{dist/client → client}/utils/request.d.ts +0 -0
- package/{dist/client → client}/utils/request.js +5 -2
- package/{dist/client → client}/utils/sync.d.ts +0 -0
- package/{dist/client → client}/utils/sync.js +0 -0
- package/{dist/client → client}/utils/task.d.ts +0 -0
- package/{dist/client → client}/utils/task.js +0 -0
- package/{dist/client → client}/utils/to-boolean.d.ts +0 -0
- package/{dist/client → client}/utils/to-boolean.js +0 -0
- package/{dist/client → client}/utils/to-event.d.ts +0 -0
- package/{dist/client → client}/utils/to-event.js +0 -0
- package/{dist/client → client}/utils/type-of.d.ts +0 -0
- package/{dist/client → client}/utils/type-of.js +0 -0
- package/{dist/client → client}/utils/update-attribute.d.ts +0 -0
- package/{dist/client → client}/utils/update-attribute.js +0 -0
- package/{dist/compiler → compiler}/compiler.d.ts +0 -0
- package/compiler/compiler.js +55 -0
- package/{dist/compiler → compiler}/index.d.ts +0 -0
- package/{dist/compiler → compiler}/index.js +0 -0
- package/compiler/plugins/componentDependencyResolver.d.ts +5 -0
- package/compiler/plugins/componentDependencyResolver.js +40 -0
- package/{dist/compiler/plugins/uhtml.d.ts → compiler/plugins/customElement.d.ts} +1 -1
- package/compiler/plugins/customElement.js +138 -0
- package/compiler/plugins/customElementReact/customElementReact.d.ts +12 -0
- package/{dist/compiler/plugins/react.proxy/react.proxy.js → compiler/plugins/customElementReact/customElementReact.js} +13 -9
- package/compiler/plugins/customElementReact/index.d.ts +1 -0
- package/compiler/plugins/customElementReact/index.js +1 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/README.md.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/_.gitignore.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/package.json.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/rollup.config.js.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/src/components/index.ts.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/src/components/{{fileName}}.compact.ts.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/src/components/{{fileName}}.ts.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/src/index.ts.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/src/proxy.ts.hbs +0 -0
- package/{dist/compiler/plugins/react.proxy → compiler/plugins/customElementReact}/templates/tsconfig.json.hbs +0 -0
- package/{dist/compiler → compiler}/plugins/docs.d.ts +0 -0
- package/{dist/compiler → compiler}/plugins/docs.js +0 -0
- package/{dist/compiler → compiler}/plugins/extract.d.ts +0 -0
- package/{dist/compiler → compiler}/plugins/extract.js +1 -8
- package/compiler/plugins/index.d.ts +7 -0
- package/compiler/plugins/index.js +7 -0
- package/{dist/compiler → compiler}/plugins/parse.d.ts +0 -0
- package/{dist/compiler → compiler}/plugins/parse.js +0 -0
- package/{dist/compiler → compiler}/plugins/read.d.ts +0 -0
- package/{dist/compiler → compiler}/plugins/read.js +0 -0
- package/compiler/plugins/style.d.ts +10 -0
- package/compiler/plugins/style.js +36 -0
- package/{dist/compiler → compiler}/plugins/validate.d.ts +0 -0
- package/compiler/plugins/validate.js +40 -0
- package/{dist/compiler → compiler}/plugins/vscode.d.ts +0 -0
- package/{dist/compiler → compiler}/plugins/vscode.js +0 -0
- package/{dist/compiler → compiler}/utils/__dirname.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/__dirname.js +0 -0
- package/{dist/compiler → compiler}/utils/get-initializer.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/get-initializer.js +0 -0
- package/{dist/compiler → compiler}/utils/get-tags.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/get-tags.js +0 -0
- package/{dist/compiler → compiler}/utils/get-type.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/get-type.js +0 -0
- package/{dist/compiler → compiler}/utils/has-decorator.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/has-decorator.js +0 -0
- package/{dist/compiler → compiler}/utils/index.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/index.js +0 -0
- package/{dist/compiler → compiler}/utils/is-directory-empty.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/is-directory-empty.js +0 -0
- package/{dist/compiler → compiler}/utils/print-type.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/print-type.js +0 -0
- package/{dist/compiler → compiler}/utils/print.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/print.js +0 -0
- package/{dist/compiler → compiler}/utils/render-template.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/render-template.js +0 -0
- package/{dist/compiler → compiler}/utils/visitor.d.ts +0 -0
- package/{dist/compiler → compiler}/utils/visitor.js +0 -0
- package/{dist/configs/constants.d.ts → constants/index.d.ts} +1 -0
- package/{dist/configs/constants.js → constants/index.js} +1 -0
- package/package.json +10 -47
- package/{dist/runtime → runtime}/index.d.ts +0 -0
- package/{dist/runtime → runtime}/index.js +0 -0
- package/{dist/types → types}/context.d.ts +3 -0
- package/{dist/types → types}/context.js +0 -0
- package/types/global.d.ts +4 -0
- package/{dist/types/plugin.js → types/global.js} +0 -0
- package/{dist/types → types}/index.d.ts +1 -0
- package/{dist/types → types}/index.js +1 -0
- package/types/plugin.d.ts +9 -0
- package/{dist/types/plus-element.js → types/plugin.js} +0 -0
- package/{dist/types → types}/plus-element.d.ts +0 -0
- package/types/plus-element.js +1 -0
- package/dist/compiler/compiler.js +0 -47
- package/dist/compiler/plugins/attach.d.ts +0 -11
- package/dist/compiler/plugins/attach.js +0 -101
- package/dist/compiler/plugins/index.d.ts +0 -11
- package/dist/compiler/plugins/index.js +0 -11
- package/dist/compiler/plugins/print.d.ts +0 -5
- package/dist/compiler/plugins/print.js +0 -11
- package/dist/compiler/plugins/react.proxy/index.d.ts +0 -1
- package/dist/compiler/plugins/react.proxy/index.js +0 -1
- package/dist/compiler/plugins/react.proxy/react.proxy.d.ts +0 -11
- package/dist/compiler/plugins/sass.d.ts +0 -6
- package/dist/compiler/plugins/sass.js +0 -15
- package/dist/compiler/plugins/uhtml.js +0 -59
- package/dist/compiler/plugins/validate.js +0 -8
- package/dist/types/plugin.d.ts +0 -8
|
@@ -10,17 +10,21 @@ const defaults = {
|
|
|
10
10
|
return `YOUR_CORE_PACKAGE_NAME#JSX.${context.componentClassName}`;
|
|
11
11
|
}
|
|
12
12
|
};
|
|
13
|
-
export const
|
|
14
|
-
const name = '
|
|
13
|
+
export const customElementReact = (options) => {
|
|
14
|
+
const name = 'customElementReact';
|
|
15
15
|
const finish = (global) => {
|
|
16
16
|
options = Object.assign(Object.assign({}, defaults), options);
|
|
17
|
-
|
|
17
|
+
// TODO
|
|
18
|
+
const globalNew = {
|
|
19
|
+
contexts: global.contexts.reduce((previous, current) => (Object.assign(Object.assign({}, previous), { [current.filePath]: current })), {}),
|
|
20
|
+
options
|
|
21
|
+
};
|
|
18
22
|
const config = { cwd: __dirname(import.meta.url) };
|
|
19
23
|
const isEmpty = isDirectoryEmpty(options.dist);
|
|
20
24
|
const skip = [];
|
|
21
25
|
const getKey = (component) => component.componentClassName;
|
|
22
|
-
for (const key in
|
|
23
|
-
const context =
|
|
26
|
+
for (const key in globalNew.contexts) {
|
|
27
|
+
const context = globalNew.contexts[key];
|
|
24
28
|
const parse = (input) => {
|
|
25
29
|
const [source, key] = input.split('#');
|
|
26
30
|
const [root, ...sub] = key.split('.');
|
|
@@ -51,7 +55,7 @@ export const reactProxy = (options) => {
|
|
|
51
55
|
renderTemplate(patterns, options.dist, config)(state);
|
|
52
56
|
}
|
|
53
57
|
if (options.compact) {
|
|
54
|
-
|
|
58
|
+
globalNew.groups = Object.values(globalNew.contexts)
|
|
55
59
|
.sort((a, b) => getKey(b).length - getKey(a).length)
|
|
56
60
|
.map((component, index, components) => ({
|
|
57
61
|
key: getKey(component),
|
|
@@ -93,7 +97,7 @@ export const reactProxy = (options) => {
|
|
|
93
97
|
};
|
|
94
98
|
})
|
|
95
99
|
.sort((a, b) => (getKey(a.root) < getKey(b.root) ? -1 : 0));
|
|
96
|
-
for (const group of
|
|
100
|
+
for (const group of globalNew.groups) {
|
|
97
101
|
if (group.single)
|
|
98
102
|
continue;
|
|
99
103
|
const state = Object.assign({ fileName: group.root.fileName, options }, group);
|
|
@@ -107,11 +111,11 @@ export const reactProxy = (options) => {
|
|
|
107
111
|
'!templates/src/components/*fileName*.ts.hbs',
|
|
108
112
|
'!templates/src/components/*fileName*.compact.ts.hbs'
|
|
109
113
|
];
|
|
110
|
-
renderTemplate(patterns, options.dist, config)(
|
|
114
|
+
renderTemplate(patterns, options.dist, config)(globalNew);
|
|
111
115
|
}
|
|
112
116
|
if (!isEmpty) {
|
|
113
117
|
const patterns = ['templates/src/proxy*', 'templates/src/components/index*'];
|
|
114
|
-
renderTemplate(patterns, options.dist, config)(
|
|
118
|
+
renderTemplate(patterns, options.dist, config)(globalNew);
|
|
115
119
|
}
|
|
116
120
|
};
|
|
117
121
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './customElementReact.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './customElementReact.js';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
2
|
import { pascalCase, paramCase } from 'change-case';
|
|
3
|
-
import fs from 'fs';
|
|
4
3
|
import path from 'path';
|
|
5
|
-
import * as CONSTANTS from '../../
|
|
4
|
+
import * as CONSTANTS from '../../constants/index.js';
|
|
6
5
|
import { hasDecorator, visitor } from '../utils/index.js';
|
|
7
6
|
export const extract = (options) => {
|
|
8
7
|
const name = 'extract';
|
|
@@ -56,12 +55,6 @@ export const extract = (options) => {
|
|
|
56
55
|
// const fileName = "dialogBodyNew"; [OK]
|
|
57
56
|
// const className = "DialogBody1"; [OK]
|
|
58
57
|
// const category = "Dialog"; [RAW]
|
|
59
|
-
(() => {
|
|
60
|
-
const stylePath = path.join(context.directoryPath, `${context.fileName}.scss`);
|
|
61
|
-
if (!fs.existsSync(stylePath))
|
|
62
|
-
return;
|
|
63
|
-
context.stylePath = stylePath;
|
|
64
|
-
})();
|
|
65
58
|
context.classEvents = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_EVENT));
|
|
66
59
|
context.classMethods = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_METHOD));
|
|
67
60
|
context.classProperties = (context.classMembers || []).filter((member) => hasDecorator(member, CONSTANTS.DECORATOR_PROPERTY));
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Context } from '../../types/index.js';
|
|
2
|
+
export declare type StyleOptions = {
|
|
3
|
+
extensions?: Array<string>;
|
|
4
|
+
directory?: (context: Context) => string;
|
|
5
|
+
filename?: (context: Context) => string;
|
|
6
|
+
};
|
|
7
|
+
export declare const style: (options: StyleOptions) => {
|
|
8
|
+
name: string;
|
|
9
|
+
next: (context: Context) => void;
|
|
10
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import t from '@babel/types';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import * as CONSTANTS from '../../constants/index.js';
|
|
5
|
+
const defaults = {
|
|
6
|
+
extensions: ['scss', 'css'],
|
|
7
|
+
directory(context) {
|
|
8
|
+
return context.directoryPath;
|
|
9
|
+
},
|
|
10
|
+
filename(context) {
|
|
11
|
+
return context.fileName;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const style = (options) => {
|
|
15
|
+
const name = 'style';
|
|
16
|
+
options = Object.assign(Object.assign({}, defaults), options);
|
|
17
|
+
const next = (context) => {
|
|
18
|
+
const filename = options.filename(context);
|
|
19
|
+
const directory = options.directory(context);
|
|
20
|
+
for (let extension of options.extensions) {
|
|
21
|
+
const stylePath = path.join(directory, `${filename}.${extension}`);
|
|
22
|
+
if (!fs.existsSync(stylePath))
|
|
23
|
+
continue;
|
|
24
|
+
context.stylePath = stylePath;
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
if (!context.stylePath)
|
|
28
|
+
return;
|
|
29
|
+
context.fileAST.program.body.unshift(t.importDeclaration([t.importDefaultSpecifier(t.identifier('AUTO_IMPORT_STYLE'))], t.stringLiteral(context.stylePath + '?inline')));
|
|
30
|
+
context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.identifier('AUTO_IMPORT_STYLE'), undefined, null, undefined, true));
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
name,
|
|
34
|
+
next
|
|
35
|
+
};
|
|
36
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
+
import { hasDecorator, visitor } from '../utils/index.js';
|
|
3
|
+
export const validate = () => {
|
|
4
|
+
const name = 'validate';
|
|
5
|
+
const next = (context) => {
|
|
6
|
+
let hasValidImport;
|
|
7
|
+
visitor(context.fileAST, {
|
|
8
|
+
ImportDeclaration(path) {
|
|
9
|
+
var _a;
|
|
10
|
+
if (((_a = path.node.source) === null || _a === void 0 ? void 0 : _a.value) !== CONSTANTS.PACKAGE_NAME)
|
|
11
|
+
return;
|
|
12
|
+
for (const specifier of path.node.specifiers) {
|
|
13
|
+
if (specifier.imported.name !== CONSTANTS.DECORATOR_ELEMENT)
|
|
14
|
+
continue;
|
|
15
|
+
hasValidImport = true;
|
|
16
|
+
path.stop();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
let hasValidExport;
|
|
21
|
+
visitor(context.fileAST, {
|
|
22
|
+
ExportNamedDeclaration(path) {
|
|
23
|
+
if (hasValidExport) {
|
|
24
|
+
hasValidExport = false;
|
|
25
|
+
return path.stop();
|
|
26
|
+
}
|
|
27
|
+
if (path.node.declaration.type !== 'ClassDeclaration')
|
|
28
|
+
return;
|
|
29
|
+
if (!hasDecorator(path.node.declaration, CONSTANTS.DECORATOR_ELEMENT))
|
|
30
|
+
return;
|
|
31
|
+
hasValidExport = true;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
context.isInvalid = !hasValidImport || !hasValidExport;
|
|
35
|
+
};
|
|
36
|
+
return {
|
|
37
|
+
name,
|
|
38
|
+
next
|
|
39
|
+
};
|
|
40
|
+
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlplus/element",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Masood Abdolian <m.abdolian@gmail.com>",
|
|
6
6
|
"description": "Compiler of HTMLPlus",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"main": "./client/index.js",
|
|
9
|
+
"types": "./client/index.d.ts",
|
|
8
10
|
"scripts": {
|
|
9
11
|
"prebuild": "npm run clean",
|
|
10
12
|
"build": "tsc",
|
|
@@ -12,53 +14,15 @@
|
|
|
12
14
|
"postbuild": "node scripts/build.post.js",
|
|
13
15
|
"clean": "rimraf dist",
|
|
14
16
|
"format": "prettier --write .",
|
|
15
|
-
"dev:start": "node src/dev/start.js",
|
|
16
|
-
"dev:build": "node src/dev/build.js"
|
|
17
|
-
},
|
|
18
|
-
"exports": {
|
|
19
|
-
".": {
|
|
20
|
-
"default": "./dist/client/index.js"
|
|
21
|
-
},
|
|
22
|
-
"./compiler": {
|
|
23
|
-
"default": "./dist/compiler/index.js"
|
|
24
|
-
},
|
|
25
|
-
"./decorators": {
|
|
26
|
-
"default": "./dist/client/decorators/index.js"
|
|
27
|
-
},
|
|
28
|
-
"./helpers": {
|
|
29
|
-
"default": "./dist/client/helpers/index.js"
|
|
30
|
-
},
|
|
31
|
-
"./runtime": {
|
|
32
|
-
"default": "./dist/runtime/index.js"
|
|
33
|
-
},
|
|
34
|
-
"./services": {
|
|
35
|
-
"default": "./dist/client/services/index.js"
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
"typesVersions": {
|
|
39
|
-
"*": {
|
|
40
|
-
"*": [
|
|
41
|
-
"./dist/client/index.d.ts"
|
|
42
|
-
],
|
|
43
|
-
"compiler": [
|
|
44
|
-
"./dist/compiler/index.d.ts"
|
|
45
|
-
],
|
|
46
|
-
"decorators": [
|
|
47
|
-
"./dist/client/decorators/index.d.ts"
|
|
48
|
-
],
|
|
49
|
-
"helpers": [
|
|
50
|
-
"./dist/client/helpers/index.d.ts"
|
|
51
|
-
],
|
|
52
|
-
"runtime": [
|
|
53
|
-
"./dist/runtime/index.d.ts"
|
|
54
|
-
],
|
|
55
|
-
"services": [
|
|
56
|
-
"./dist/client/services/index.d.ts"
|
|
57
|
-
]
|
|
58
|
-
}
|
|
17
|
+
"dev:start": "node src/dev/scripts/start.js",
|
|
18
|
+
"dev:build": "node src/dev/scripts/build.js"
|
|
59
19
|
},
|
|
60
20
|
"files": [
|
|
61
|
-
"
|
|
21
|
+
"client",
|
|
22
|
+
"compiler",
|
|
23
|
+
"constants",
|
|
24
|
+
"runtime",
|
|
25
|
+
"types",
|
|
62
26
|
"package.json",
|
|
63
27
|
"README.md"
|
|
64
28
|
],
|
|
@@ -84,7 +48,6 @@
|
|
|
84
48
|
"fast-glob": "^3.2.11",
|
|
85
49
|
"handlebars": "^4.7.7",
|
|
86
50
|
"log-update": "^5.0.0",
|
|
87
|
-
"sass": "^1.43.4",
|
|
88
51
|
"ts-node": "^10.4.0",
|
|
89
52
|
"typescript": "^4.5.2",
|
|
90
53
|
"uhtml": "^2.7.6"
|
|
File without changes
|
|
File without changes
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
|
|
2
2
|
export interface Context {
|
|
3
|
+
dependencies?: Array<Context>;
|
|
4
|
+
dependenciesUnresolved?: Array<string>;
|
|
5
|
+
isInvalid?: boolean;
|
|
3
6
|
script?: string;
|
|
4
7
|
componentClassName?: string;
|
|
5
8
|
componentInterfaceName?: string;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Context } from './context.js';
|
|
2
|
+
import { Global } from './global';
|
|
3
|
+
export declare type Return<T> = void | T | Promise<T>;
|
|
4
|
+
export declare type Plugin = {
|
|
5
|
+
name: string;
|
|
6
|
+
start?: (global: Global) => Return<Global>;
|
|
7
|
+
next?: (context: Context, global: Global) => Return<Context>;
|
|
8
|
+
finish?: (global: Global) => Return<Global>;
|
|
9
|
+
};
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import logUpdate from 'log-update';
|
|
2
|
-
const log = (namespace, message) => {
|
|
3
|
-
logUpdate(`${new Date().toLocaleTimeString()} [@htmlplus/element]${namespace ? `[${namespace}]` : ''} ${message}`);
|
|
4
|
-
};
|
|
5
|
-
export default (...plugins) => {
|
|
6
|
-
let global = {
|
|
7
|
-
contexts: {}
|
|
8
|
-
};
|
|
9
|
-
const start = async () => {
|
|
10
|
-
log(undefined, 'Starting.');
|
|
11
|
-
for (const plugin of plugins) {
|
|
12
|
-
if (!plugin.start)
|
|
13
|
-
continue;
|
|
14
|
-
global = (await plugin.start(global)) || global;
|
|
15
|
-
log(plugin.name, 'Started successfully.');
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
const next = async (filePath) => {
|
|
19
|
-
const key = filePath.split(/[\/|\\]/g).pop();
|
|
20
|
-
let context = {
|
|
21
|
-
filePath
|
|
22
|
-
};
|
|
23
|
-
for (const plugin of plugins) {
|
|
24
|
-
if (!plugin.next)
|
|
25
|
-
continue;
|
|
26
|
-
context = (await plugin.next(context, global)) || context;
|
|
27
|
-
log(`${key}:${plugin.name}`, 'Executed successfully.');
|
|
28
|
-
}
|
|
29
|
-
log(key, 'Executed successfully.');
|
|
30
|
-
global.contexts[filePath] = context;
|
|
31
|
-
return context;
|
|
32
|
-
};
|
|
33
|
-
const finish = async () => {
|
|
34
|
-
for (const plugin of plugins) {
|
|
35
|
-
if (!plugin.finish)
|
|
36
|
-
continue;
|
|
37
|
-
global = (await plugin.finish(global)) || global;
|
|
38
|
-
log(plugin.name, 'Finished successfully.');
|
|
39
|
-
}
|
|
40
|
-
log(undefined, 'Finished.');
|
|
41
|
-
};
|
|
42
|
-
return {
|
|
43
|
-
start,
|
|
44
|
-
next,
|
|
45
|
-
finish
|
|
46
|
-
};
|
|
47
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Context } from '../../types/index.js';
|
|
2
|
-
export interface AttachOptions {
|
|
3
|
-
dependencies?: boolean;
|
|
4
|
-
members?: boolean;
|
|
5
|
-
styles?: boolean;
|
|
6
|
-
typings?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const attach: (options: AttachOptions) => {
|
|
9
|
-
name: string;
|
|
10
|
-
next: (context: Context) => void;
|
|
11
|
-
};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import t from '@babel/types';
|
|
2
|
-
import * as CONSTANTS from '../../configs/constants.js';
|
|
3
|
-
import { visitor } from '../utils/index.js';
|
|
4
|
-
const defaults = {
|
|
5
|
-
dependencies: true,
|
|
6
|
-
members: true,
|
|
7
|
-
styles: true,
|
|
8
|
-
typings: true
|
|
9
|
-
};
|
|
10
|
-
export const attach = (options) => {
|
|
11
|
-
options = Object.assign({}, defaults, options);
|
|
12
|
-
const name = 'attach';
|
|
13
|
-
const next = (context) => {
|
|
14
|
-
// TODO
|
|
15
|
-
if (options.dependencies) {
|
|
16
|
-
}
|
|
17
|
-
if (options.styles && context.styleParsed)
|
|
18
|
-
context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_STYLES), t.stringLiteral(context.styleParsed), undefined, null, undefined, true));
|
|
19
|
-
if (options.members) {
|
|
20
|
-
context.class.body.body.unshift(t.classProperty(t.identifier(CONSTANTS.STATIC_MEMBERS), t.objectExpression([
|
|
21
|
-
...context.classProperties.map((property) => {
|
|
22
|
-
var _a, _b;
|
|
23
|
-
const type = (_b = (_a = property.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation) === null || _b === void 0 ? void 0 : _b.type;
|
|
24
|
-
const elements = [];
|
|
25
|
-
switch (type) {
|
|
26
|
-
case 'TSBooleanKeyword':
|
|
27
|
-
elements.push(t.stringLiteral(CONSTANTS.TYPE_BOOLEAN));
|
|
28
|
-
break;
|
|
29
|
-
case 'TSStringKeyword':
|
|
30
|
-
elements.push(t.stringLiteral(CONSTANTS.TYPE_STRING));
|
|
31
|
-
break;
|
|
32
|
-
case 'TSNumberKeyword':
|
|
33
|
-
elements.push(t.stringLiteral(CONSTANTS.TYPE_NUMBER));
|
|
34
|
-
break;
|
|
35
|
-
default:
|
|
36
|
-
elements.push(t.nullLiteral());
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
if (property.value)
|
|
40
|
-
elements.push(property.value);
|
|
41
|
-
return t.objectProperty(t.identifier(property.key['name']), t.arrayExpression(elements));
|
|
42
|
-
}),
|
|
43
|
-
...context.classMethods.map((method) => {
|
|
44
|
-
const elements = [t.stringLiteral(CONSTANTS.TYPE_FUNCTION)];
|
|
45
|
-
return t.objectProperty(t.identifier(method.key['name']), t.arrayExpression(elements));
|
|
46
|
-
})
|
|
47
|
-
]), undefined, undefined, undefined, true));
|
|
48
|
-
}
|
|
49
|
-
if (options.typings) {
|
|
50
|
-
visitor(context.fileAST, {
|
|
51
|
-
Program(path) {
|
|
52
|
-
path.node.body.push(Object.assign(t.tsModuleDeclaration(t.identifier('global'), t.tsModuleBlock([
|
|
53
|
-
t.tsInterfaceDeclaration(t.identifier(context.componentInterfaceName), null, [], t.tsInterfaceBody([
|
|
54
|
-
...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
|
|
55
|
-
optional: property.optional,
|
|
56
|
-
leadingComments: property.leadingComments
|
|
57
|
-
}))
|
|
58
|
-
])),
|
|
59
|
-
t.variableDeclaration('var', [
|
|
60
|
-
t.variableDeclarator(Object.assign(t.identifier(context.componentInterfaceName), {
|
|
61
|
-
typeAnnotation: t.tSTypeAnnotation(t.tSTypeLiteral([
|
|
62
|
-
t.tSPropertySignature(t.identifier('prototype'), t.tsTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName)))),
|
|
63
|
-
t.tSConstructSignatureDeclaration(null, [], t.tSTypeAnnotation(t.tSTypeReference(t.identifier(context.componentInterfaceName))))
|
|
64
|
-
]))
|
|
65
|
-
}))
|
|
66
|
-
]),
|
|
67
|
-
t.tsInterfaceDeclaration(t.identifier('HTMLElementTagNameMap'), null, [], t.tsInterfaceBody([
|
|
68
|
-
t.tSPropertySignature(t.stringLiteral(context.componentTag), t.tSTypeAnnotation(t.tSIntersectionType([t.tSTypeReference(t.identifier(context.componentInterfaceName))])))
|
|
69
|
-
]))
|
|
70
|
-
])), {
|
|
71
|
-
declare: true,
|
|
72
|
-
global: true
|
|
73
|
-
}));
|
|
74
|
-
path.node.body.push(t.exportNamedDeclaration(t.tsInterfaceDeclaration(
|
|
75
|
-
// TODO
|
|
76
|
-
t.identifier(context.componentClassName + 'JSX'), null, [], t.tsInterfaceBody([
|
|
77
|
-
...context.classProperties.map((property) => Object.assign(t.tSPropertySignature(property.key, property.typeAnnotation), {
|
|
78
|
-
optional: property.optional,
|
|
79
|
-
leadingComments: property.leadingComments
|
|
80
|
-
})),
|
|
81
|
-
...context.classEvents.map((event) => {
|
|
82
|
-
var _a, _b;
|
|
83
|
-
return Object.assign(t.tSPropertySignature(event.key, t.tsTypeAnnotation(t.tsFunctionType(undefined, [
|
|
84
|
-
Object.assign({}, t.identifier('event'), {
|
|
85
|
-
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))
|
|
86
|
-
})
|
|
87
|
-
], t.tsTypeAnnotation(t.tsVoidKeyword())))), {
|
|
88
|
-
optional: true,
|
|
89
|
-
leadingComments: event.leadingComments
|
|
90
|
-
});
|
|
91
|
-
})
|
|
92
|
-
]))));
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
name,
|
|
99
|
-
next
|
|
100
|
-
};
|
|
101
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './react.proxy/index.js';
|
|
2
|
-
export * from './attach.js';
|
|
3
|
-
export * from './docs.js';
|
|
4
|
-
export * from './extract.js';
|
|
5
|
-
export * from './parse.js';
|
|
6
|
-
export * from './print.js';
|
|
7
|
-
export * from './read.js';
|
|
8
|
-
export * from './sass.js';
|
|
9
|
-
export * from './uhtml.js';
|
|
10
|
-
export * from './validate.js';
|
|
11
|
-
export * from './vscode.js';
|