@viewfly/core 0.0.1-alpha.9 → 0.0.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 +3 -1
- package/bundles/foundation/_utils.d.ts +4 -13
- package/bundles/foundation/renderer.d.ts +0 -1
- package/bundles/index.esm.js +265 -328
- package/bundles/index.js +265 -329
- package/bundles/jsx.d.ts +13 -0
- package/bundles/model/component.d.ts +14 -15
- package/bundles/model/jsx-element.d.ts +9 -23
- package/bundles/public-api.d.ts +1 -0
- package/bundles/viewfly.d.ts +2 -3
- package/jsx-runtime/index.d.ts +18 -0
- package/jsx-runtime/package.json +5 -0
- package/package.json +4 -7
- package/jsx-dev-runtime.js +0 -8
- package/jsx-runtime.d.ts +0 -16
- /package/{jsx-runtime.js → jsx-runtime/index.esm.js} +0 -0
- /package/{jsx-runtime.umd.js → jsx-runtime/index.js} +0 -0
package/bundles/jsx.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Key, Ref } from '@viewfly/core';
|
|
2
|
+
export declare namespace JSX {
|
|
3
|
+
interface Attributes<T extends object> {
|
|
4
|
+
ref?: Ref<T> | Ref<T>[];
|
|
5
|
+
key?: Key;
|
|
6
|
+
}
|
|
7
|
+
interface ElementClass {
|
|
8
|
+
}
|
|
9
|
+
interface IntrinsicElements {
|
|
10
|
+
}
|
|
11
|
+
interface IntrinsicAttributes {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { Provider, ReflectiveInjector, AbstractType, Type, InjectionToken, InjectFlags, Injector } from '@tanbo/di';
|
|
2
|
-
import {
|
|
2
|
+
import { Props, Key, JSXTypeof, JSXChildNode } from './jsx-element';
|
|
3
3
|
export declare class JSXComponent {
|
|
4
4
|
createInstance: (injector: Component) => Component;
|
|
5
5
|
constructor(createInstance: (injector: Component) => Component);
|
|
6
6
|
}
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
(props?: T): () => JSXTemplate;
|
|
7
|
+
export interface ComponentSetup<T extends Props<any> = Props<any>> {
|
|
8
|
+
(props?: T): () => JSXChildNode;
|
|
10
9
|
}
|
|
11
10
|
/**
|
|
12
11
|
* Viewfly 组件管理类,用于管理组件的生命周期,上下文等
|
|
13
12
|
*/
|
|
14
13
|
export declare class Component extends ReflectiveInjector implements JSXTypeof {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
type: ComponentSetup;
|
|
15
|
+
props: Props<any>;
|
|
17
16
|
key?: Key | undefined;
|
|
18
|
-
$$typeOf: ComponentSetup<
|
|
17
|
+
$$typeOf: ComponentSetup<Props<any>>;
|
|
19
18
|
destroyCallbacks: LifeCycleCallback[];
|
|
20
19
|
mountCallbacks: LifeCycleCallback[];
|
|
21
20
|
propsChangedCallbacks: PropsChangedCallback<any>[];
|
|
22
21
|
updatedCallbacks: LifeCycleCallback[];
|
|
23
|
-
props: Props;
|
|
24
22
|
get dirty(): boolean;
|
|
25
23
|
get changed(): boolean;
|
|
26
24
|
protected _dirty: boolean;
|
|
@@ -28,18 +26,19 @@ export declare class Component extends ReflectiveInjector implements JSXTypeof {
|
|
|
28
26
|
private parentComponent;
|
|
29
27
|
private updatedDestroyCallbacks;
|
|
30
28
|
private propsChangedDestroyCallbacks;
|
|
29
|
+
private unWatch?;
|
|
31
30
|
private isFirstRending;
|
|
32
|
-
constructor(context: Injector,
|
|
31
|
+
constructor(context: Injector, type: ComponentSetup, props: Props<any>, key?: Key | undefined);
|
|
33
32
|
is(target: JSXTypeof): boolean;
|
|
34
33
|
addProvide<T>(providers: Provider<T> | Provider<T>[]): void;
|
|
35
34
|
init(): {
|
|
36
|
-
template:
|
|
37
|
-
render: () =>
|
|
35
|
+
template: JSXChildNode;
|
|
36
|
+
render: () => JSXChildNode;
|
|
38
37
|
};
|
|
39
38
|
markAsDirtied(): void;
|
|
40
39
|
markAsChanged(): void;
|
|
41
40
|
rendered(): void;
|
|
42
|
-
invokePropsChangedHooks(newProps
|
|
41
|
+
invokePropsChangedHooks(newProps: Props<any>): void;
|
|
43
42
|
destroy(): void;
|
|
44
43
|
private invokeMountHooks;
|
|
45
44
|
private invokeUpdatedHooks;
|
|
@@ -47,7 +46,7 @@ export declare class Component extends ReflectiveInjector implements JSXTypeof {
|
|
|
47
46
|
export interface LifeCycleCallback {
|
|
48
47
|
(): void | (() => void);
|
|
49
48
|
}
|
|
50
|
-
export interface PropsChangedCallback<T extends
|
|
49
|
+
export interface PropsChangedCallback<T extends Props<any>> {
|
|
51
50
|
(currentProps: T | null, oldProps: T | null): void | (() => void);
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
@@ -62,7 +61,7 @@ export interface PropsChangedCallback<T extends JSXProps<any>> {
|
|
|
62
61
|
* }
|
|
63
62
|
* ```
|
|
64
63
|
*/
|
|
65
|
-
export declare function
|
|
64
|
+
export declare function onMounted(callback: LifeCycleCallback): void;
|
|
66
65
|
/**
|
|
67
66
|
* 当组件视图更新后调用
|
|
68
67
|
* @param callback
|
|
@@ -98,7 +97,7 @@ export declare function onUpdated(callback: LifeCycleCallback): () => void;
|
|
|
98
97
|
* }
|
|
99
98
|
* ```
|
|
100
99
|
*/
|
|
101
|
-
export declare function onPropsChanged<T extends
|
|
100
|
+
export declare function onPropsChanged<T extends Props<any>>(callback: PropsChangedCallback<T>): () => void;
|
|
102
101
|
/**
|
|
103
102
|
* 当组件销毁时调用回调函数
|
|
104
103
|
* @param callback
|
|
@@ -1,45 +1,31 @@
|
|
|
1
1
|
import { JSXComponent, ComponentSetup } from './component';
|
|
2
2
|
export type JSXChildNode = JSXElement | JSXComponent | string | number | boolean | null | undefined | JSXChildNode[];
|
|
3
|
-
export interface
|
|
3
|
+
export interface Props<T = JSXChildNode | JSXChildNode[]> {
|
|
4
4
|
children?: T;
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
[key: symbol]: any;
|
|
7
7
|
}
|
|
8
|
-
export declare const Fragment: () =>
|
|
8
|
+
export declare const Fragment: (props: Props) => () => JSXChildNode | JSXChildNode[];
|
|
9
9
|
export type Key = number | string;
|
|
10
|
-
export declare function jsx<T extends JSXChildNode>(name: string, config
|
|
11
|
-
export declare function jsx<T extends JSXChildNode>(setup: ComponentSetup, config
|
|
12
|
-
export declare function jsxs<T extends JSXChildNode[]>(name: string, config
|
|
13
|
-
export declare function jsxs<T extends JSXChildNode[]>(setup: ComponentSetup, config
|
|
10
|
+
export declare function jsx<T extends JSXChildNode>(name: string, config: Props<T>, key?: Key): JSXElement;
|
|
11
|
+
export declare function jsx<T extends JSXChildNode>(setup: ComponentSetup, config: Props<T>, key?: Key): JSXComponent;
|
|
12
|
+
export declare function jsxs<T extends JSXChildNode[]>(name: string, config: Props<T>, key?: Key): JSXElement;
|
|
13
|
+
export declare function jsxs<T extends JSXChildNode[]>(setup: ComponentSetup, config: Props<T>, key?: Key): JSXComponent;
|
|
14
14
|
export interface JSXTypeof {
|
|
15
15
|
$$typeOf: string | ComponentSetup;
|
|
16
16
|
is(target: JSXTypeof): boolean;
|
|
17
17
|
}
|
|
18
|
-
export interface VElementListeners {
|
|
19
|
-
[listenKey: string]: <T extends Event>(ev: T) => any;
|
|
20
|
-
}
|
|
21
18
|
export declare class JSXText implements JSXTypeof {
|
|
22
19
|
text: string;
|
|
23
20
|
$$typeOf: string;
|
|
24
21
|
constructor(text: string);
|
|
25
22
|
is(target: JSXTypeof): boolean;
|
|
26
23
|
}
|
|
27
|
-
export declare class Props {
|
|
28
|
-
attrs: Map<string, any>;
|
|
29
|
-
styles: Map<string, string | number>;
|
|
30
|
-
classes: string;
|
|
31
|
-
listeners: VElementListeners;
|
|
32
|
-
children: JSXChildNode[];
|
|
33
|
-
constructor(props?: JSXProps<JSXChildNode> | JSXProps<JSXChildNode[]> | null);
|
|
34
|
-
static classToString(config: unknown): any;
|
|
35
|
-
static classToArray(config: unknown): string[];
|
|
36
|
-
}
|
|
37
24
|
export declare class JSXElement implements JSXTypeof {
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
type: string;
|
|
26
|
+
props: Props<any>;
|
|
40
27
|
key?: Key | undefined;
|
|
41
28
|
$$typeOf: string;
|
|
42
|
-
props: Props;
|
|
43
|
-
constructor(name: string, config?: JSXProps<any> | null | undefined, key?: Key | undefined);
|
|
29
|
+
constructor(type: string, props: Props<any>, key?: Key | undefined);
|
|
44
30
|
is(target: JSXTypeof): boolean;
|
|
45
31
|
}
|
package/bundles/public-api.d.ts
CHANGED
package/bundles/viewfly.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ export type RootNode = JSXElement | JSXComponent;
|
|
|
6
6
|
* Viewfly 配置项
|
|
7
7
|
*/
|
|
8
8
|
export interface Config {
|
|
9
|
-
/** 应用根节点 */
|
|
10
|
-
host: NativeNode;
|
|
11
9
|
/** Viewfly IoC 容器中提供者集合 */
|
|
12
10
|
providers?: Provider[];
|
|
13
11
|
/** 是否自动更新视图 */
|
|
@@ -28,8 +26,9 @@ export declare class Viewfly extends ReflectiveInjector {
|
|
|
28
26
|
constructor(config: Config);
|
|
29
27
|
/**
|
|
30
28
|
* 启动 Viewfly
|
|
29
|
+
* @param host 应用根节点
|
|
31
30
|
*/
|
|
32
|
-
|
|
31
|
+
mount(host: NativeNode): void;
|
|
33
32
|
/**
|
|
34
33
|
* 销毁 Viewfly 实例
|
|
35
34
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { JSXComponent, jsx, jsxs, Fragment } from '@viewfly/core'
|
|
2
|
+
import type { NativeElements } from '@viewfly/platform-browser'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* JSX namespace for usage with @jsxImportsSource directive
|
|
6
|
+
* when ts compilerOptions.jsx is 'react-jsx'
|
|
7
|
+
* https://www.typescriptlang.org/tsconfig#jsxImportSource
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export { jsx, jsxs, Fragment }
|
|
11
|
+
|
|
12
|
+
export namespace JSX {
|
|
13
|
+
export interface ElementClass extends JSXComponent {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface IntrinsicElements extends NativeElements {
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Viewfly is a simple and easy-to-use JavaScript framework with an intuitive development experience.",
|
|
5
5
|
"main": "./bundles/index.js",
|
|
6
6
|
"module": "./bundles/index.esm.js",
|
|
7
7
|
"typings": "./bundles/public-api.d.ts",
|
|
8
8
|
"scripts": {
|
|
9
|
-
"start": "webpack-dev-server",
|
|
10
|
-
"test": "cross-env env=test jest",
|
|
11
|
-
"test-c": "cross-env env=test jest --coverage",
|
|
12
9
|
"build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
13
10
|
"publish:lib": "npm run build:lib && npm publish --access=public"
|
|
14
11
|
},
|
|
15
12
|
"license": "MIT",
|
|
16
13
|
"keywords": [],
|
|
17
14
|
"dependencies": {
|
|
18
|
-
"@tanbo/di": "^1.1.
|
|
19
|
-
"@tanbo/stream": "^1.
|
|
15
|
+
"@tanbo/di": "^1.1.5",
|
|
16
|
+
"@tanbo/stream": "^1.2.0",
|
|
20
17
|
"reflect-metadata": "^0.1.13"
|
|
21
18
|
},
|
|
22
19
|
"devDependencies": {
|
|
@@ -37,5 +34,5 @@
|
|
|
37
34
|
"bugs": {
|
|
38
35
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
39
36
|
},
|
|
40
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "65bcb20399ed7e6e14102b649588135a7ebf4a72"
|
|
41
38
|
}
|
package/jsx-dev-runtime.js
DELETED
package/jsx-runtime.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment, JSXElement } from '@viewfly/core'
|
|
2
|
-
|
|
3
|
-
export {
|
|
4
|
-
jsxs,
|
|
5
|
-
jsx,
|
|
6
|
-
Fragment
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
declare namespace JSX {
|
|
10
|
-
interface IntrinsicElements {
|
|
11
|
-
[elemName: string]: JSXElement
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
interface Element extends JSXElement {
|
|
15
|
-
}
|
|
16
|
-
}
|
|
File without changes
|
|
File without changes
|