@htmlplus/element 0.1.9 → 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 +34 -4
- package/package.json +10 -47
- 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 -17
- package/dist/client/utils/request.d.ts +0 -2
- package/dist/client/utils/request.js +0 -25
- 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 -46
- 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 -56
- package/dist/compiler/index.d.ts +0 -2
- package/dist/compiler/index.js +0 -2
- package/dist/compiler/plugins/attach.d.ts +0 -11
- package/dist/compiler/plugins/attach.js +0 -101
- 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 -77
- package/dist/compiler/plugins/index.d.ts +0 -11
- package/dist/compiler/plugins/index.js +0 -11
- package/dist/compiler/plugins/parse.d.ts +0 -5
- package/dist/compiler/plugins/parse.js +0 -16
- 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/react.proxy/react.proxy.js +0 -121
- package/dist/compiler/plugins/react.proxy/templates/README.md.hbs +0 -1
- package/dist/compiler/plugins/react.proxy/templates/_.gitignore.hbs +0 -2
- package/dist/compiler/plugins/react.proxy/templates/package.json.hbs +0 -37
- package/dist/compiler/plugins/react.proxy/templates/rollup.config.js.hbs +0 -21
- package/dist/compiler/plugins/react.proxy/templates/src/components/index.ts.hbs +0 -17
- package/dist/compiler/plugins/react.proxy/templates/src/components/{{fileName}}.compact.ts.hbs +0 -18
- package/dist/compiler/plugins/react.proxy/templates/src/components/{{fileName}}.ts.hbs +0 -26
- package/dist/compiler/plugins/react.proxy/templates/src/index.ts.hbs +0 -1
- package/dist/compiler/plugins/react.proxy/templates/src/proxy.ts.hbs +0 -278
- package/dist/compiler/plugins/react.proxy/templates/tsconfig.json.hbs +0 -17
- package/dist/compiler/plugins/read.d.ts +0 -5
- package/dist/compiler/plugins/read.js +0 -13
- package/dist/compiler/plugins/sass.d.ts +0 -6
- package/dist/compiler/plugins/sass.js +0 -15
- package/dist/compiler/plugins/uhtml.d.ts +0 -5
- package/dist/compiler/plugins/uhtml.js +0 -59
- package/dist/compiler/plugins/validate.d.ts +0 -5
- package/dist/compiler/plugins/validate.js +0 -8
- 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/configs/constants.d.ts +0 -22
- package/dist/configs/constants.js +0 -28
- package/dist/runtime/index.d.ts +0 -1
- package/dist/runtime/index.js +0 -4
- package/dist/types/context.d.ts +0 -29
- package/dist/types/context.js +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -3
- package/dist/types/plugin.d.ts +0 -8
- 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,11 +0,0 @@
|
|
|
1
|
-
import { Context } from '../../types/index.js';
|
|
2
|
-
export interface VscodeOptions {
|
|
3
|
-
dist: string;
|
|
4
|
-
prefix: string;
|
|
5
|
-
}
|
|
6
|
-
export declare const vscode: (options: VscodeOptions) => {
|
|
7
|
-
name: string;
|
|
8
|
-
start: (global: any) => void;
|
|
9
|
-
next: (context: Context, global: any) => void;
|
|
10
|
-
finish: (global: any) => void;
|
|
11
|
-
};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { paramCase } from 'change-case';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import path from 'path';
|
|
4
|
-
import { getTags, getType, printType } from '../utils/index.js';
|
|
5
|
-
export const vscode = (options) => {
|
|
6
|
-
const name = 'vscode';
|
|
7
|
-
const start = (global) => {
|
|
8
|
-
global.vscode = {
|
|
9
|
-
version: 1.1,
|
|
10
|
-
tags: []
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
const next = (context, global) => {
|
|
14
|
-
const readme = (() => {
|
|
15
|
-
try {
|
|
16
|
-
const source = path.resolve(context.directoryPath || '', `${context.fileName}.md`);
|
|
17
|
-
return fs.readFileSync(source, 'utf8');
|
|
18
|
-
}
|
|
19
|
-
catch (_a) { }
|
|
20
|
-
})();
|
|
21
|
-
const description = (() => {
|
|
22
|
-
const content = readme || '';
|
|
23
|
-
if (!content.startsWith('# '))
|
|
24
|
-
return '';
|
|
25
|
-
const sections = content.split('\n');
|
|
26
|
-
for (let i = 1; i < sections.length; i++) {
|
|
27
|
-
const section = sections[i].trim();
|
|
28
|
-
if (!section)
|
|
29
|
-
continue;
|
|
30
|
-
return section;
|
|
31
|
-
}
|
|
32
|
-
return '';
|
|
33
|
-
})();
|
|
34
|
-
const properties = (context.classProperties || []).map((property) => {
|
|
35
|
-
var _a;
|
|
36
|
-
const name = paramCase(property.key['name']);
|
|
37
|
-
const description = (_a = getTags(property).find((tag) => !tag.key)) === null || _a === void 0 ? void 0 : _a.value;
|
|
38
|
-
const attribute = {
|
|
39
|
-
name,
|
|
40
|
-
description
|
|
41
|
-
};
|
|
42
|
-
// TODO
|
|
43
|
-
let { members = [] } = (() => {
|
|
44
|
-
const ast = getType(context.fileAST, (property.typeAnnotation || {})['typeAnnotation'], {
|
|
45
|
-
directory: context.directoryPath
|
|
46
|
-
});
|
|
47
|
-
return printType(ast);
|
|
48
|
-
})();
|
|
49
|
-
// TODO
|
|
50
|
-
members = members.filter((member) => member.key !== member.type).map((member) => ({ name: member.key }));
|
|
51
|
-
if (members.length)
|
|
52
|
-
attribute.values = members;
|
|
53
|
-
return attribute;
|
|
54
|
-
});
|
|
55
|
-
global.vscode.tags.push({
|
|
56
|
-
name: context.componentKey,
|
|
57
|
-
description: {
|
|
58
|
-
kind: 'markdown',
|
|
59
|
-
value: description
|
|
60
|
-
},
|
|
61
|
-
attributes: properties,
|
|
62
|
-
references: [
|
|
63
|
-
{
|
|
64
|
-
name: 'Source code',
|
|
65
|
-
url: `https://github.com/htmlplus/core/tree/main/src/components/${context.directoryName}/${context.fileName}.tsx`
|
|
66
|
-
}
|
|
67
|
-
]
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
const finish = (global) => {
|
|
71
|
-
global.vscode.tags = global.vscode.tags.sort((a, b) => (a.name > b.name ? 1 : -1));
|
|
72
|
-
// TODO
|
|
73
|
-
// fs.ensureDirSync(path.dirname(options.dist));
|
|
74
|
-
// TODO
|
|
75
|
-
// fs.writeJSONSync(options.dist, global.vscode, { replacer: null, spaces: 2 });
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
name,
|
|
79
|
-
start,
|
|
80
|
-
next,
|
|
81
|
-
finish
|
|
82
|
-
};
|
|
83
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const __dirname: (url: string | URL) => string;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export const getTags = (node) => {
|
|
2
|
-
if (!node)
|
|
3
|
-
return [];
|
|
4
|
-
const tags = [];
|
|
5
|
-
const lines = [];
|
|
6
|
-
const comments = (node.leadingComments || [])
|
|
7
|
-
.map((comment) => comment.value)
|
|
8
|
-
.join('\r\n')
|
|
9
|
-
.split('\r\n');
|
|
10
|
-
for (const comment of comments) {
|
|
11
|
-
let line = comment.trimLeft();
|
|
12
|
-
if (line.startsWith('*'))
|
|
13
|
-
line = line.slice(1);
|
|
14
|
-
if (!line)
|
|
15
|
-
continue;
|
|
16
|
-
const isTag = line.trim().startsWith('@');
|
|
17
|
-
if (isTag || !lines.length)
|
|
18
|
-
lines.push(line);
|
|
19
|
-
else
|
|
20
|
-
lines[lines.length - 1] += line;
|
|
21
|
-
}
|
|
22
|
-
for (const line of lines) {
|
|
23
|
-
let value = line.trim();
|
|
24
|
-
if (!value.startsWith('@')) {
|
|
25
|
-
tags.push({ value });
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
const sections = value.split(' ');
|
|
29
|
-
const key = sections[0].slice(1);
|
|
30
|
-
value = sections.slice(1).join(' ').trim();
|
|
31
|
-
tags.push({ key, value });
|
|
32
|
-
}
|
|
33
|
-
return tags;
|
|
34
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { parse } from '@babel/parser';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import { dirname, resolve } from 'path';
|
|
4
|
-
import { visitor } from './visitor.js';
|
|
5
|
-
// TODO: return type
|
|
6
|
-
export const getType = (file, node, options) => {
|
|
7
|
-
if (!node)
|
|
8
|
-
return node;
|
|
9
|
-
if (node.type != 'TSTypeReference')
|
|
10
|
-
return node;
|
|
11
|
-
const { directory } = options;
|
|
12
|
-
let result;
|
|
13
|
-
visitor(file, {
|
|
14
|
-
ClassDeclaration(path) {
|
|
15
|
-
if (path.node.id.name != node.typeName.name)
|
|
16
|
-
return;
|
|
17
|
-
result = path.node;
|
|
18
|
-
path.stop();
|
|
19
|
-
},
|
|
20
|
-
ImportDeclaration(path) {
|
|
21
|
-
for (const specifier of path.node.specifiers) {
|
|
22
|
-
const alias = specifier.local.name;
|
|
23
|
-
if (alias != node.typeName.name)
|
|
24
|
-
continue;
|
|
25
|
-
let key;
|
|
26
|
-
switch (specifier.type) {
|
|
27
|
-
case 'ImportNamespaceSpecifier':
|
|
28
|
-
key = '*';
|
|
29
|
-
break;
|
|
30
|
-
case 'ImportDefaultSpecifier':
|
|
31
|
-
key = 'default';
|
|
32
|
-
break;
|
|
33
|
-
case 'ImportSpecifier':
|
|
34
|
-
key = specifier.imported.name;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
try {
|
|
38
|
-
const filePath = resolve(directory, path.node.source.value + '.ts');
|
|
39
|
-
path.$ast =
|
|
40
|
-
path.$ast ||
|
|
41
|
-
parse(fs.readFileSync(filePath, 'utf8'), {
|
|
42
|
-
allowImportExportEverywhere: true,
|
|
43
|
-
plugins: ['typescript'],
|
|
44
|
-
ranges: false
|
|
45
|
-
});
|
|
46
|
-
result = getType(path.$ast, node, {
|
|
47
|
-
directory: dirname(filePath)
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
catch (_a) { }
|
|
51
|
-
path.stop();
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
TSInterfaceDeclaration(path) {
|
|
56
|
-
if (path.node.id.name != node.typeName.name)
|
|
57
|
-
return;
|
|
58
|
-
result = path.node;
|
|
59
|
-
path.stop();
|
|
60
|
-
},
|
|
61
|
-
TSTypeAliasDeclaration(path) {
|
|
62
|
-
if (path.node.id.name != node.typeName.name)
|
|
63
|
-
return;
|
|
64
|
-
result = path.node;
|
|
65
|
-
path.stop();
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return result || node;
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const hasDecorator: (node: any, name: string) => boolean;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './__dirname.js';
|
|
2
|
-
export * from './get-initializer.js';
|
|
3
|
-
export * from './get-tags.js';
|
|
4
|
-
export * from './get-type.js';
|
|
5
|
-
export * from './has-decorator.js';
|
|
6
|
-
export * from './is-directory-empty.js';
|
|
7
|
-
export * from './print-type.js';
|
|
8
|
-
export * from './print.js';
|
|
9
|
-
export * from './render-template.js';
|
|
10
|
-
export * from './visitor.js';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './__dirname.js';
|
|
2
|
-
export * from './get-initializer.js';
|
|
3
|
-
export * from './get-tags.js';
|
|
4
|
-
export * from './get-type.js';
|
|
5
|
-
export * from './has-decorator.js';
|
|
6
|
-
export * from './is-directory-empty.js';
|
|
7
|
-
export * from './print-type.js';
|
|
8
|
-
export * from './print.js';
|
|
9
|
-
export * from './render-template.js';
|
|
10
|
-
export * from './visitor.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isDirectoryEmpty: (directory: string) => boolean;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const printType: (ast: any) => any;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { print } from './print.js';
|
|
2
|
-
// TODO
|
|
3
|
-
// args types
|
|
4
|
-
// return type
|
|
5
|
-
// components\grid-item\grid-item.types.ts
|
|
6
|
-
// components\portal\portal.tsx
|
|
7
|
-
export const printType = (ast) => {
|
|
8
|
-
if (!ast)
|
|
9
|
-
return ast;
|
|
10
|
-
let result = {};
|
|
11
|
-
switch (ast.type) {
|
|
12
|
-
case 'BooleanLiteral':
|
|
13
|
-
case 'NumericLiteral':
|
|
14
|
-
case 'StringLiteral': {
|
|
15
|
-
result.key = ast.value;
|
|
16
|
-
result.type = ast.type.replace('Literal', '').toLowerCase();
|
|
17
|
-
break;
|
|
18
|
-
}
|
|
19
|
-
case 'TSBooleanKeyword':
|
|
20
|
-
case 'TSNumberKeyword':
|
|
21
|
-
case 'TSStringKeyword': {
|
|
22
|
-
const type = ast.type.replace('TS', '').replace('Keyword', '').toLowerCase();
|
|
23
|
-
result.key = type;
|
|
24
|
-
result.type = type;
|
|
25
|
-
break;
|
|
26
|
-
}
|
|
27
|
-
case 'TSAnyKeyword': {
|
|
28
|
-
result.type = 'any';
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case 'TSArrayType': {
|
|
32
|
-
const type = print(ast.elementType) + '[]';
|
|
33
|
-
result.key = type;
|
|
34
|
-
result.type = type;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
case 'TSInterfaceDeclaration': {
|
|
38
|
-
result.type = ast.id.name;
|
|
39
|
-
result.members = ast.body.body.map((body) => printType(body));
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
case 'TSLiteralType': {
|
|
43
|
-
result = printType(ast.literal);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
case 'TSPropertySignature': {
|
|
47
|
-
const { typeAnnotation } = ast;
|
|
48
|
-
result.key = ast.key.name;
|
|
49
|
-
if (typeAnnotation && typeAnnotation.typeAnnotation)
|
|
50
|
-
result.type = printType(ast.typeAnnotation.typeAnnotation).type;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
case 'TSTypeAliasDeclaration': {
|
|
54
|
-
result = printType(ast.typeAnnotation);
|
|
55
|
-
break;
|
|
56
|
-
}
|
|
57
|
-
case 'TSTypeReference': {
|
|
58
|
-
result.key = ast.typeName.name;
|
|
59
|
-
result.type = ast.typeName.name;
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
case 'TSUnionType': {
|
|
63
|
-
result.type = print(ast);
|
|
64
|
-
result.members = ast.types.map((type) => printType(type));
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const renderTemplate: (source: string | Array<string>, destination: string, options?: any) => (context: any) => void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import glob from 'fast-glob';
|
|
2
|
-
import fs from 'fs';
|
|
3
|
-
import handlebars from 'handlebars';
|
|
4
|
-
import path from 'path';
|
|
5
|
-
export const renderTemplate = (source, destination, options) => (context) => {
|
|
6
|
-
const files = glob.sync(source, options);
|
|
7
|
-
for (const file of files) {
|
|
8
|
-
const from = path.resolve((options === null || options === void 0 ? void 0 : options.cwd) || '', file);
|
|
9
|
-
const to = path.join(destination, path
|
|
10
|
-
.normalize(file)
|
|
11
|
-
.split(path.sep)
|
|
12
|
-
.slice(1)
|
|
13
|
-
.map((section) => handlebars.compile(section)(context))
|
|
14
|
-
.join(path.sep)
|
|
15
|
-
.replace('_.', '.')
|
|
16
|
-
.replace('.hbs', ''));
|
|
17
|
-
const directory = path.dirname(to);
|
|
18
|
-
const raw = fs.readFileSync(from, 'utf8');
|
|
19
|
-
const template = handlebars.compile(raw)(context);
|
|
20
|
-
if (!fs.existsSync(directory)) {
|
|
21
|
-
fs.mkdirSync(directory, { recursive: true });
|
|
22
|
-
}
|
|
23
|
-
fs.writeFileSync(to, template, 'utf8');
|
|
24
|
-
}
|
|
25
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export declare const API_HOST = "$host$";
|
|
2
|
-
export declare const API_READY = "$ready$";
|
|
3
|
-
export declare const API_SETUP = "$setup$";
|
|
4
|
-
export declare const DECORATOR_ELEMENT = "Element";
|
|
5
|
-
export declare const DECORATOR_EVENT = "Event";
|
|
6
|
-
export declare const DECORATOR_PROPERTY = "Property";
|
|
7
|
-
export declare const DECORATOR_STATE = "State";
|
|
8
|
-
export declare const DECORATOR_METHOD = "Method";
|
|
9
|
-
export declare const LIFECYCLE_ADOPTED = "adoptedCallback";
|
|
10
|
-
export declare const LIFECYCLE_CONNECTED = "connectedCallback";
|
|
11
|
-
export declare const LIFECYCLE_DISCONNECTED = "disconnectedCallback";
|
|
12
|
-
export declare const LIFECYCLE_LOADED = "loadedCallback";
|
|
13
|
-
export declare const LIFECYCLE_UPDATE = "updateCallback";
|
|
14
|
-
export declare const LIFECYCLE_UPDATED = "updatedCallback";
|
|
15
|
-
export declare const METHOD_RENDER = "render";
|
|
16
|
-
export declare const STATIC_MEMBERS = "members";
|
|
17
|
-
export declare const STATIC_STYLES = "styles";
|
|
18
|
-
export declare const TYPE_BOOLEAN = "boolean";
|
|
19
|
-
export declare const TYPE_DATE = "date";
|
|
20
|
-
export declare const TYPE_FUNCTION = "function";
|
|
21
|
-
export declare const TYPE_STRING = "string";
|
|
22
|
-
export declare const TYPE_NUMBER = "number";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// apis
|
|
2
|
-
export const API_HOST = '$host$';
|
|
3
|
-
export const API_READY = '$ready$';
|
|
4
|
-
export const API_SETUP = '$setup$';
|
|
5
|
-
// decorators
|
|
6
|
-
export const DECORATOR_ELEMENT = 'Element';
|
|
7
|
-
export const DECORATOR_EVENT = 'Event';
|
|
8
|
-
export const DECORATOR_PROPERTY = 'Property';
|
|
9
|
-
export const DECORATOR_STATE = 'State';
|
|
10
|
-
export const DECORATOR_METHOD = 'Method';
|
|
11
|
-
// lifecycle
|
|
12
|
-
export const LIFECYCLE_ADOPTED = 'adoptedCallback';
|
|
13
|
-
export const LIFECYCLE_CONNECTED = 'connectedCallback';
|
|
14
|
-
export const LIFECYCLE_DISCONNECTED = 'disconnectedCallback';
|
|
15
|
-
export const LIFECYCLE_LOADED = 'loadedCallback';
|
|
16
|
-
export const LIFECYCLE_UPDATE = 'updateCallback';
|
|
17
|
-
export const LIFECYCLE_UPDATED = 'updatedCallback';
|
|
18
|
-
// methods
|
|
19
|
-
export const METHOD_RENDER = 'render';
|
|
20
|
-
// statics
|
|
21
|
-
export const STATIC_MEMBERS = 'members';
|
|
22
|
-
export const STATIC_STYLES = 'styles';
|
|
23
|
-
// types
|
|
24
|
-
export const TYPE_BOOLEAN = 'boolean';
|
|
25
|
-
export const TYPE_DATE = 'date';
|
|
26
|
-
export const TYPE_FUNCTION = 'function';
|
|
27
|
-
export const TYPE_STRING = 'string';
|
|
28
|
-
export const TYPE_NUMBER = 'number';
|
package/dist/runtime/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const html: (template: any, ...values: any[]) => any;
|
package/dist/runtime/index.js
DELETED
package/dist/types/context.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ClassBody, ClassDeclaration, ClassMethod, ClassProperty, File } from '@babel/types';
|
|
2
|
-
export interface Context {
|
|
3
|
-
script?: string;
|
|
4
|
-
componentClassName?: string;
|
|
5
|
-
componentInterfaceName?: string;
|
|
6
|
-
componentKey?: string;
|
|
7
|
-
componentTag?: string;
|
|
8
|
-
directoryName?: string;
|
|
9
|
-
directoryPath?: string;
|
|
10
|
-
fileAST?: File;
|
|
11
|
-
fileContent?: string;
|
|
12
|
-
fileExtension?: string;
|
|
13
|
-
fileName?: string;
|
|
14
|
-
filePath?: string;
|
|
15
|
-
styleContent?: string;
|
|
16
|
-
styleDependencies?: Array<string>;
|
|
17
|
-
styleParsed?: string;
|
|
18
|
-
stylePath?: string;
|
|
19
|
-
class?: ClassDeclaration;
|
|
20
|
-
classEvents?: Array<ClassProperty>;
|
|
21
|
-
classHasMount?: boolean;
|
|
22
|
-
classHasUnmount?: boolean;
|
|
23
|
-
classMembers?: ClassBody['body'];
|
|
24
|
-
classMethods?: Array<ClassMethod>;
|
|
25
|
-
className?: string;
|
|
26
|
-
classProperties?: Array<ClassProperty>;
|
|
27
|
-
classRender?: ClassMethod;
|
|
28
|
-
classStates?: Array<ClassProperty>;
|
|
29
|
-
}
|
package/dist/types/context.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
package/dist/types/index.js
DELETED
package/dist/types/plugin.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Context } from './context.js';
|
|
2
|
-
export declare type Return<T> = void | T | Promise<T>;
|
|
3
|
-
export declare type Plugin = {
|
|
4
|
-
name: string;
|
|
5
|
-
start?: (global: any) => Return<any>;
|
|
6
|
-
next?: (context: Context, global: any) => Return<Context>;
|
|
7
|
-
finish?: (global: any) => Return<any>;
|
|
8
|
-
};
|
package/dist/types/plugin.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|