@htmlplus/element 0.4.5 → 0.4.8
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/bundlers/index.d.ts +2 -0
- package/bundlers/index.js +2 -0
- package/bundlers/rollup.d.ts +7 -0
- package/bundlers/rollup.js +21 -0
- package/bundlers/vite.d.ts +7 -0
- package/bundlers/vite.js +25 -0
- package/client/decorators/attributes.d.ts +1 -1
- package/client/decorators/attributes.js +4 -4
- package/client/decorators/element.d.ts +1 -1
- package/client/decorators/element.js +14 -22
- package/client/decorators/event.d.ts +1 -1
- package/client/decorators/listen.d.ts +1 -1
- package/client/decorators/method.d.ts +1 -1
- package/client/decorators/property.d.ts +1 -1
- package/client/decorators/property.js +4 -4
- package/client/decorators/state.d.ts +1 -1
- package/client/decorators/state.js +4 -4
- package/client/decorators/watch.d.ts +1 -1
- package/client/helpers/direction.d.ts +1 -1
- package/client/helpers/isRTL.d.ts +1 -1
- package/client/helpers/slots.d.ts +1 -1
- package/client/utils/getMemberType.d.ts +1 -1
- package/client/utils/getMemberType.js +2 -2
- package/client/utils/getMembersKey.d.ts +1 -1
- package/client/utils/getStyles.d.ts +1 -1
- package/client/utils/host.d.ts +1 -1
- package/client/utils/index.d.ts +1 -1
- package/client/utils/index.js +1 -1
- package/client/utils/request.d.ts +1 -1
- package/client/utils/request.js +3 -3
- package/client/utils/syncAttributes.d.ts +1 -0
- package/client/utils/{sync.js → syncAttributes.js} +1 -1
- package/client/{vendor → vendors}/uhtml.d.ts +7 -0
- package/client/{vendor → vendors}/uhtml.js +1 -0
- package/compiler/compiler.d.ts +1 -1
- package/compiler/plugins/assets.d.ts +1 -1
- package/compiler/plugins/copy.d.ts +13 -0
- package/compiler/plugins/copy.js +26 -0
- package/compiler/plugins/customElement.d.ts +1 -1
- package/compiler/plugins/customElement.js +31 -38
- package/compiler/plugins/customElementReact/customElementReact.d.ts +1 -1
- package/compiler/plugins/document.d.ts +1 -1
- package/compiler/plugins/document.js +37 -35
- package/compiler/plugins/extract.d.ts +1 -1
- package/compiler/plugins/index.d.ts +1 -0
- package/compiler/plugins/index.js +1 -0
- package/compiler/plugins/parse.d.ts +1 -1
- package/compiler/plugins/read.d.ts +1 -1
- package/compiler/plugins/style.d.ts +2 -2
- package/compiler/plugins/style.js +6 -2
- package/compiler/plugins/validate.d.ts +1 -1
- package/compiler/plugins/visualStudioCode.d.ts +1 -1
- package/compiler/plugins/webTypes.d.ts +2 -2
- package/compiler/plugins/webTypes.js +75 -51
- package/compiler/utils/addDependency.d.ts +9 -2
- package/compiler/utils/addDependency.js +35 -16
- package/compiler/utils/getInitializer.d.ts +1 -1
- package/compiler/utils/getInitializer.js +2 -8
- package/compiler/utils/index.d.ts +1 -0
- package/compiler/utils/index.js +1 -0
- package/compiler/utils/removeUnusedImport.d.ts +1 -0
- package/compiler/utils/removeUnusedImport.js +49 -0
- package/constants/index.d.ts +9 -2
- package/constants/index.js +10 -2
- package/package.json +5 -11
- package/types/global.d.ts +1 -1
- package/types/index.d.ts +4 -4
- package/types/index.js +4 -4
- package/types/plugin.d.ts +1 -1
- package/client/utils/sync.d.ts +0 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import compiler from '../compiler/index.js';
|
|
2
|
+
export const rollup = (...plugins) => {
|
|
3
|
+
const { start, next, finish } = compiler(...plugins);
|
|
4
|
+
return {
|
|
5
|
+
name: 'htmlplus',
|
|
6
|
+
async buildStart() {
|
|
7
|
+
await start();
|
|
8
|
+
},
|
|
9
|
+
async load(id) {
|
|
10
|
+
if (!id.endsWith('.tsx'))
|
|
11
|
+
return;
|
|
12
|
+
const { isInvalid, script } = await next(id);
|
|
13
|
+
if (isInvalid)
|
|
14
|
+
return;
|
|
15
|
+
return script;
|
|
16
|
+
},
|
|
17
|
+
async buildEnd() {
|
|
18
|
+
await finish();
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
package/bundlers/vite.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import compiler from '../compiler/index.js';
|
|
3
|
+
export const vite = (...plugins) => {
|
|
4
|
+
const { start, next, finish } = compiler(...plugins);
|
|
5
|
+
return {
|
|
6
|
+
name: 'htmlplus',
|
|
7
|
+
async buildStart() {
|
|
8
|
+
await start();
|
|
9
|
+
},
|
|
10
|
+
async load(id) {
|
|
11
|
+
if (!id.endsWith('.tsx'))
|
|
12
|
+
return;
|
|
13
|
+
let { isInvalid, script, stylePath } = await next(id);
|
|
14
|
+
if (isInvalid)
|
|
15
|
+
return;
|
|
16
|
+
if (script && stylePath) {
|
|
17
|
+
script = script.replace(path.basename(stylePath), `${path.basename(stylePath)}?inline`);
|
|
18
|
+
}
|
|
19
|
+
return script;
|
|
20
|
+
},
|
|
21
|
+
async buildEnd() {
|
|
22
|
+
await finish();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare function Attributes(): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
-
import { appendToMethod, host,
|
|
2
|
+
import { appendToMethod, host, syncAttributes } from '../utils/index.js';
|
|
3
3
|
export function Attributes() {
|
|
4
4
|
return function (target, propertyKey) {
|
|
5
|
-
const
|
|
5
|
+
const symbol = Symbol();
|
|
6
6
|
appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
|
|
7
|
-
|
|
7
|
+
this[symbol] = syncAttributes(host(this));
|
|
8
8
|
});
|
|
9
9
|
appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function () {
|
|
10
|
-
|
|
10
|
+
this[symbol](this[propertyKey]);
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare function Element(tag?: string): (constructor: PlusElement) => void;
|
|
@@ -1,58 +1,50 @@
|
|
|
1
1
|
import { camelCase, paramCase } from 'change-case';
|
|
2
2
|
import * as CONSTANTS from '../../constants/index.js';
|
|
3
3
|
import { call, getMembersKey, getMemberType, isServer, parseValue, request } from '../utils/index.js';
|
|
4
|
-
import * as uhtml from '../vendor/uhtml.js';
|
|
5
4
|
export function Element(tag) {
|
|
6
5
|
return function (constructor) {
|
|
7
6
|
if (isServer())
|
|
8
7
|
return;
|
|
9
8
|
if (customElements.get(tag))
|
|
10
9
|
return;
|
|
11
|
-
const instances = new Map();
|
|
12
10
|
class Plus extends HTMLElement {
|
|
13
11
|
constructor() {
|
|
14
12
|
super();
|
|
15
13
|
this.attachShadow({ mode: 'open' });
|
|
16
14
|
// TODO
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
instance['uhtml'] = uhtml;
|
|
21
|
-
instance[CONSTANTS.API_STATUS] = 'initialize';
|
|
15
|
+
this[CONSTANTS.API_INSTANCE] = new constructor();
|
|
16
|
+
this[CONSTANTS.API_INSTANCE][CONSTANTS.API_HOST] = () => this;
|
|
17
|
+
this[CONSTANTS.API_INSTANCE][CONSTANTS.API_STATUS] = 'initialize';
|
|
22
18
|
}
|
|
19
|
+
// TODO: ignore functions
|
|
23
20
|
static get observedAttributes() {
|
|
24
|
-
// TODO: ignore functions
|
|
25
21
|
return getMembersKey(constructor).map((key) => paramCase(key));
|
|
26
22
|
}
|
|
27
23
|
adoptedCallback() {
|
|
28
|
-
|
|
29
|
-
call(instance, CONSTANTS.LIFECYCLE_ADOPTED);
|
|
24
|
+
call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_ADOPTED);
|
|
30
25
|
}
|
|
31
26
|
// TODO
|
|
32
27
|
attributeChangedCallback(name, prev, next) {
|
|
33
|
-
const instance = instances.get(this);
|
|
34
28
|
const key = camelCase(name);
|
|
35
|
-
const type = getMemberType(
|
|
29
|
+
const type = getMemberType(this[CONSTANTS.API_INSTANCE], key);
|
|
36
30
|
const parsed = parseValue(next, type);
|
|
37
|
-
|
|
31
|
+
this[CONSTANTS.API_INSTANCE][key] = parsed;
|
|
38
32
|
}
|
|
39
33
|
connectedCallback() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
request(instance)
|
|
34
|
+
this[CONSTANTS.API_INSTANCE][CONSTANTS.API_STATUS] = 'connected';
|
|
35
|
+
call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_CONNECTED);
|
|
36
|
+
request(this[CONSTANTS.API_INSTANCE])
|
|
44
37
|
.then(() => {
|
|
45
|
-
|
|
46
|
-
call(
|
|
38
|
+
this[CONSTANTS.API_INSTANCE][CONSTANTS.API_STATUS] = 'loaded';
|
|
39
|
+
call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_LOADED);
|
|
47
40
|
})
|
|
48
41
|
.catch((error) => {
|
|
49
42
|
throw error;
|
|
50
43
|
});
|
|
51
44
|
}
|
|
52
45
|
disconnectedCallback() {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
call(instance, CONSTANTS.LIFECYCLE_DISCONNECTED);
|
|
46
|
+
this[CONSTANTS.API_INSTANCE][CONSTANTS.API_STATUS] = 'disconnected';
|
|
47
|
+
call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_DISCONNECTED);
|
|
56
48
|
}
|
|
57
49
|
}
|
|
58
50
|
customElements.define(tag, Plus);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare function Method(): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -5,16 +5,16 @@ export function Property(options) {
|
|
|
5
5
|
return function (target, propertyKey) {
|
|
6
6
|
const name = String(propertyKey);
|
|
7
7
|
const attribute = paramCase(name);
|
|
8
|
+
const symbol = Symbol();
|
|
8
9
|
const type = getMemberType(target, name);
|
|
9
|
-
const values = new Map();
|
|
10
10
|
function get() {
|
|
11
|
-
return
|
|
11
|
+
return this[symbol];
|
|
12
12
|
}
|
|
13
13
|
function set(input) {
|
|
14
|
-
const value =
|
|
14
|
+
const value = this[symbol];
|
|
15
15
|
if (input === value)
|
|
16
16
|
return;
|
|
17
|
-
|
|
17
|
+
this[symbol] = input;
|
|
18
18
|
const isReady = this[CONSTANTS.API_STATUS] == 'initialize';
|
|
19
19
|
request(this, { [name]: [input, value] }).then(() => {
|
|
20
20
|
const element = host(this);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare function State(): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -2,15 +2,15 @@ import { defineProperty, request } from '../utils/index.js';
|
|
|
2
2
|
export function State() {
|
|
3
3
|
return function (target, propertyKey) {
|
|
4
4
|
const name = String(propertyKey);
|
|
5
|
-
const
|
|
5
|
+
const symbol = Symbol();
|
|
6
6
|
function get() {
|
|
7
|
-
return
|
|
7
|
+
return this[symbol];
|
|
8
8
|
}
|
|
9
9
|
function set(input) {
|
|
10
|
-
const value =
|
|
10
|
+
const value = this[symbol];
|
|
11
11
|
if (input === value)
|
|
12
12
|
return;
|
|
13
|
-
|
|
13
|
+
this[symbol] = input;
|
|
14
14
|
request(this, { [name]: [input, value] })
|
|
15
15
|
.then(() => undefined)
|
|
16
16
|
.catch((error) => {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare const isRTL: (target: PlusElement) => boolean;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare const getMemberType: (target: PlusElement, key: string) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
2
|
export const getMemberType = (target, key) => {
|
|
3
|
-
var _a;
|
|
4
|
-
return (_a = (target.constructor[CONSTANTS.STATIC_MEMBERS] || target[CONSTANTS.STATIC_MEMBERS] ||
|
|
3
|
+
var _a, _b;
|
|
4
|
+
return (_b = (_a = (target.constructor[CONSTANTS.STATIC_MEMBERS] || target[CONSTANTS.STATIC_MEMBERS])) === null || _a === void 0 ? void 0 : _a[key]) === null || _b === void 0 ? void 0 : _b[CONSTANTS.STATIC_MEMBERS_TYPE];
|
|
5
5
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare const getMembersKey: (target: PlusElement) => string[];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare const getStyles: (target: PlusElement) => string | undefined;
|
package/client/utils/host.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { PlusElement } from '../../types
|
|
1
|
+
import { PlusElement } from '../../types';
|
|
2
2
|
export declare const host: (target: PlusElement) => HTMLElement;
|
package/client/utils/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export * from './off.js';
|
|
|
13
13
|
export * from './on.js';
|
|
14
14
|
export * from './parseValue.js';
|
|
15
15
|
export * from './request.js';
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './syncAttributes.js';
|
|
17
17
|
export * from './task.js';
|
|
18
18
|
export * from './toBoolean.js';
|
|
19
19
|
export * from './toEvent.js';
|
package/client/utils/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export * from './off.js';
|
|
|
13
13
|
export * from './on.js';
|
|
14
14
|
export * from './parseValue.js';
|
|
15
15
|
export * from './request.js';
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './syncAttributes.js';
|
|
17
17
|
export * from './task.js';
|
|
18
18
|
export * from './toBoolean.js';
|
|
19
19
|
export * from './toEvent.js';
|
package/client/utils/request.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
-
import { call } from '../utils/call';
|
|
3
|
-
import { task } from '../utils/task';
|
|
4
|
-
import { html, render } from '../
|
|
2
|
+
import { call } from '../utils/call.js';
|
|
3
|
+
import { task } from '../utils/task.js';
|
|
4
|
+
import { html, render } from '../vendors/uhtml.js';
|
|
5
5
|
import { getStyles } from './getStyles.js';
|
|
6
6
|
import { host } from './host.js';
|
|
7
7
|
const targets = new Map();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const syncAttributes: (node: HTMLElement) => (next?: any) => void;
|
|
@@ -3,7 +3,7 @@ import { off } from './off.js';
|
|
|
3
3
|
import { on } from './on.js';
|
|
4
4
|
import { toEvent } from './toEvent.js';
|
|
5
5
|
import { updateAttribute } from './updateAttribute.js';
|
|
6
|
-
export const
|
|
6
|
+
export const syncAttributes = (node) => {
|
|
7
7
|
let prev = {};
|
|
8
8
|
return (next = {}) => {
|
|
9
9
|
const prevClass = (prev.class || '').split(' ');
|
package/compiler/compiler.d.ts
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface CopyOptions {
|
|
2
|
+
at?: 'finish' | 'start';
|
|
3
|
+
destination: string;
|
|
4
|
+
source: string;
|
|
5
|
+
transformer?: (parameters: {
|
|
6
|
+
content: string;
|
|
7
|
+
}) => string;
|
|
8
|
+
}
|
|
9
|
+
export declare const copy: (options: CopyOptions) => {
|
|
10
|
+
name: string;
|
|
11
|
+
start: () => void;
|
|
12
|
+
finish: () => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
const defaults = {
|
|
4
|
+
at: 'finish',
|
|
5
|
+
};
|
|
6
|
+
export const copy = (options) => {
|
|
7
|
+
const name = 'copy';
|
|
8
|
+
options = Object.assign({}, defaults, options);
|
|
9
|
+
const copy = (caller) => {
|
|
10
|
+
if (options.at != caller)
|
|
11
|
+
return;
|
|
12
|
+
let content;
|
|
13
|
+
content = fs.readFileSync(options.source, 'utf8');
|
|
14
|
+
if (options.transformer)
|
|
15
|
+
content = options.transformer({ content });
|
|
16
|
+
fs.ensureDirSync(path.dirname(options.destination));
|
|
17
|
+
fs.writeFileSync(options.destination, content, 'utf8');
|
|
18
|
+
};
|
|
19
|
+
const start = () => {
|
|
20
|
+
copy('start');
|
|
21
|
+
};
|
|
22
|
+
const finish = () => {
|
|
23
|
+
copy('finish');
|
|
24
|
+
};
|
|
25
|
+
return { name, start, finish };
|
|
26
|
+
};
|
|
@@ -21,20 +21,15 @@ export const customElement = (options) => {
|
|
|
21
21
|
return;
|
|
22
22
|
if (value.type != 'JSXExpressionContainer')
|
|
23
23
|
return;
|
|
24
|
-
const local = addDependency(
|
|
24
|
+
const { local } = addDependency(path, CONSTANTS.PACKAGE_NAME, CONSTANTS.UTILS_STYLE_MAP, CONSTANTS.UTILS_STYLE_MAP);
|
|
25
|
+
// TODO: remove 'local!'
|
|
25
26
|
path.replaceWith(t.jsxAttribute(t.jsxIdentifier('style'), t.jsxExpressionContainer(t.callExpression(t.identifier(local), [value.expression]))));
|
|
26
27
|
path.skip();
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
// TODO
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const { body, id } = path.node;
|
|
33
|
-
if (id.name != context.className)
|
|
34
|
-
return;
|
|
35
|
-
body.body.unshift(t.classProperty(t.identifier('uhtml')));
|
|
36
|
-
}
|
|
37
|
-
});
|
|
31
|
+
const { node } = addDependency(ast, CONSTANTS.VENDOR_UHTML, 'uhtml');
|
|
32
|
+
t.addComment(node, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_DEPENDENCY, true);
|
|
38
33
|
// replace 'className' attribute to 'class'
|
|
39
34
|
visitor(ast, {
|
|
40
35
|
JSXAttribute(path) {
|
|
@@ -67,17 +62,15 @@ export const customElement = (options) => {
|
|
|
67
62
|
exit(path) {
|
|
68
63
|
if (path.parent.type == 'JSXElement' || path.parent.type == 'JSXFragment') {
|
|
69
64
|
path.replaceWith(t.identifier(print(path.node)));
|
|
70
|
-
return;
|
|
71
65
|
}
|
|
72
66
|
else {
|
|
73
|
-
path.replaceWith(t.memberExpression(t.
|
|
74
|
-
return;
|
|
67
|
+
path.replaceWith(t.memberExpression(t.identifier('uhtml'), t.identifier(`html\`${print(path.node)}\``)));
|
|
75
68
|
}
|
|
76
69
|
}
|
|
77
70
|
},
|
|
78
71
|
JSXFragment: {
|
|
79
72
|
exit(path) {
|
|
80
|
-
path.replaceWith(t.memberExpression(t.
|
|
73
|
+
path.replaceWith(t.memberExpression(t.identifier('uhtml'), t.identifier(['html`', ...path.node.children.map((child) => print(child)), '`'].join(''))));
|
|
81
74
|
}
|
|
82
75
|
},
|
|
83
76
|
JSXExpressionContainer: {
|
|
@@ -101,34 +94,34 @@ export const customElement = (options) => {
|
|
|
101
94
|
const { body, id } = path.node;
|
|
102
95
|
if (id.name != context.className)
|
|
103
96
|
return;
|
|
104
|
-
|
|
97
|
+
const node = t.classProperty(t.identifier(CONSTANTS.STATIC_MEMBERS), t.objectExpression([
|
|
105
98
|
...context.classProperties.map((property) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
99
|
+
const properties = [];
|
|
100
|
+
if (property.value) {
|
|
101
|
+
properties.push(t.objectProperty(t.identifier(CONSTANTS.STATIC_MEMBERS_INITIALIZER), property.value));
|
|
102
|
+
}
|
|
103
|
+
const type = (() => {
|
|
104
|
+
var _a, _b;
|
|
105
|
+
switch ((_b = (_a = property.typeAnnotation) === null || _a === void 0 ? void 0 : _a.typeAnnotation) === null || _b === void 0 ? void 0 : _b.type) {
|
|
106
|
+
case 'TSBooleanKeyword':
|
|
107
|
+
return t.stringLiteral(CONSTANTS.TYPE_BOOLEAN);
|
|
108
|
+
case 'TSStringKeyword':
|
|
109
|
+
return t.stringLiteral(CONSTANTS.TYPE_STRING);
|
|
110
|
+
case 'TSNumberKeyword':
|
|
111
|
+
return t.stringLiteral(CONSTANTS.TYPE_NUMBER);
|
|
112
|
+
}
|
|
113
|
+
})();
|
|
114
|
+
if (type) {
|
|
115
|
+
properties.push(t.objectProperty(t.identifier(CONSTANTS.STATIC_MEMBERS_TYPE), type));
|
|
122
116
|
}
|
|
123
|
-
|
|
124
|
-
elements.push(property.value);
|
|
125
|
-
return t.objectProperty(t.identifier(property.key['name']), t.arrayExpression(elements));
|
|
117
|
+
return t.objectProperty(t.identifier(property.key['name']), t.objectExpression(properties));
|
|
126
118
|
}),
|
|
127
|
-
...context.classMethods.map((method) =>
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
119
|
+
...context.classMethods.map((method) => t.objectProperty(t.identifier(method.key['name']), t.objectExpression([
|
|
120
|
+
t.objectProperty(t.identifier(CONSTANTS.STATIC_MEMBERS_TYPE), t.stringLiteral(CONSTANTS.TYPE_FUNCTION))
|
|
121
|
+
])))
|
|
122
|
+
]), undefined, undefined, undefined, true);
|
|
123
|
+
t.addComment(node, 'leading', CONSTANTS.COMMENT_AUTO_ADDED_PROPERTY, true);
|
|
124
|
+
body.body.unshift(node);
|
|
132
125
|
}
|
|
133
126
|
});
|
|
134
127
|
// attach typings
|