@viewfly/core 0.0.14 → 0.0.15
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/bundles/index.esm.js +3 -10
- package/bundles/index.js +3 -10
- package/bundles/model/_api.d.ts +1 -0
- package/bundles/model/component.d.ts +12 -21
- package/bundles/model/jsx-element.d.ts +11 -12
- package/bundles/model/memo.d.ts +3 -6
- package/bundles/model/root.component.d.ts +3 -2
- package/bundles/model/types.d.ts +27 -0
- package/bundles/public-api.d.ts +0 -1
- package/bundles/viewfly.d.ts +2 -3
- package/jsx-runtime/index.d.ts +8 -6
- package/jsx-runtime/package.json +2 -2
- package/package.json +3 -4
- package/bundles/types.d.ts +0 -19
package/bundles/index.esm.js
CHANGED
|
@@ -608,20 +608,12 @@ function inject(token, notFoundValue, flags) {
|
|
|
608
608
|
return component.parentInjector.get(token, notFoundValue, flags);
|
|
609
609
|
}
|
|
610
610
|
|
|
611
|
-
|
|
611
|
+
function Fragment(props) {
|
|
612
612
|
return () => {
|
|
613
613
|
return props.children;
|
|
614
614
|
};
|
|
615
|
-
};
|
|
616
|
-
function jsx(setup, props, key) {
|
|
617
|
-
if (typeof setup === 'string') {
|
|
618
|
-
return new JSXElement(setup, props, key);
|
|
619
|
-
}
|
|
620
|
-
return new JSXComponent(props, function (context, props) {
|
|
621
|
-
return new Component(context, setup, props, key);
|
|
622
|
-
});
|
|
623
615
|
}
|
|
624
|
-
function
|
|
616
|
+
function jsx(setup, props, key) {
|
|
625
617
|
if (typeof setup === 'string') {
|
|
626
618
|
return new JSXElement(setup, props, key);
|
|
627
619
|
}
|
|
@@ -629,6 +621,7 @@ function jsxs(setup, props, key) {
|
|
|
629
621
|
return new Component(context, setup, props, key);
|
|
630
622
|
});
|
|
631
623
|
}
|
|
624
|
+
const jsxs = jsx;
|
|
632
625
|
class JSXText {
|
|
633
626
|
constructor(text) {
|
|
634
627
|
this.text = text;
|
package/bundles/index.js
CHANGED
|
@@ -609,20 +609,12 @@ function inject(token, notFoundValue, flags) {
|
|
|
609
609
|
return component.parentInjector.get(token, notFoundValue, flags);
|
|
610
610
|
}
|
|
611
611
|
|
|
612
|
-
|
|
612
|
+
function Fragment(props) {
|
|
613
613
|
return () => {
|
|
614
614
|
return props.children;
|
|
615
615
|
};
|
|
616
|
-
};
|
|
617
|
-
function jsx(setup, props, key) {
|
|
618
|
-
if (typeof setup === 'string') {
|
|
619
|
-
return new JSXElement(setup, props, key);
|
|
620
|
-
}
|
|
621
|
-
return new JSXComponent(props, function (context, props) {
|
|
622
|
-
return new Component(context, setup, props, key);
|
|
623
|
-
});
|
|
624
616
|
}
|
|
625
|
-
function
|
|
617
|
+
function jsx(setup, props, key) {
|
|
626
618
|
if (typeof setup === 'string') {
|
|
627
619
|
return new JSXElement(setup, props, key);
|
|
628
620
|
}
|
|
@@ -630,6 +622,7 @@ function jsxs(setup, props, key) {
|
|
|
630
622
|
return new Component(context, setup, props, key);
|
|
631
623
|
});
|
|
632
624
|
}
|
|
625
|
+
const jsxs = jsx;
|
|
633
626
|
class JSXText {
|
|
634
627
|
constructor(text) {
|
|
635
628
|
this.text = text;
|
package/bundles/model/_api.d.ts
CHANGED
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
import { Provider, ReflectiveInjector, AbstractType, Type, InjectionToken, InjectFlags, Injector } from '@tanbo/di';
|
|
2
|
-
import { Props, Key, JSXTypeof
|
|
2
|
+
import { Props, Key, JSXTypeof } from './jsx-element';
|
|
3
|
+
import { JSXInternal } from './types';
|
|
3
4
|
export declare class JSXComponent {
|
|
4
5
|
props: Props;
|
|
5
6
|
private factory;
|
|
6
7
|
constructor(props: Props, factory: (injector: Component, props: Props) => Component);
|
|
7
8
|
createInstance(injector: Component): Component;
|
|
8
9
|
}
|
|
9
|
-
export interface ComponentInstance<T> {
|
|
10
|
-
$render(): JSXChildNode;
|
|
11
|
-
$shouldUpdate?(currentProps: T, prevProps: T): unknown;
|
|
12
|
-
}
|
|
13
|
-
export interface Renderable {
|
|
14
|
-
$render(): any;
|
|
15
|
-
}
|
|
16
|
-
export interface ComponentSetup<T extends Props<any> = Props<any>> {
|
|
17
|
-
(props?: T): (() => JSXChildNode) | ComponentInstance<T>;
|
|
18
|
-
}
|
|
19
10
|
/**
|
|
20
11
|
* Viewfly 组件管理类,用于管理组件的生命周期,上下文等
|
|
21
12
|
*/
|
|
22
13
|
export declare class Component extends ReflectiveInjector implements JSXTypeof {
|
|
23
|
-
type:
|
|
24
|
-
props: Props
|
|
14
|
+
type: JSXInternal.ElementClass;
|
|
15
|
+
props: Props;
|
|
25
16
|
key?: Key | undefined;
|
|
26
|
-
$$typeOf:
|
|
17
|
+
$$typeOf: JSXInternal.ElementClass<any>;
|
|
27
18
|
destroyCallbacks: LifeCycleCallback[];
|
|
28
19
|
mountCallbacks: LifeCycleCallback[];
|
|
29
20
|
propsChangedCallbacks: PropsChangedCallback<any>[];
|
|
@@ -37,12 +28,12 @@ export declare class Component extends ReflectiveInjector implements JSXTypeof {
|
|
|
37
28
|
private propsChangedDestroyCallbacks;
|
|
38
29
|
private unWatch?;
|
|
39
30
|
private isFirstRending;
|
|
40
|
-
constructor(context: Injector, type:
|
|
31
|
+
constructor(context: Injector, type: JSXInternal.ElementClass, props: Props, key?: Key | undefined);
|
|
41
32
|
is(target: JSXTypeof): boolean;
|
|
42
33
|
addProvide<T>(providers: Provider<T> | Provider<T>[]): void;
|
|
43
34
|
init(): {
|
|
44
|
-
template: JSXChildNode;
|
|
45
|
-
render: (newProps: Props, oldProps: Props) => JSXChildNode;
|
|
35
|
+
template: JSXInternal.JSXChildNode;
|
|
36
|
+
render: (newProps: Props, oldProps: Props) => JSXInternal.JSXChildNode;
|
|
46
37
|
};
|
|
47
38
|
markAsDirtied(): void;
|
|
48
39
|
markAsChanged(): void;
|
|
@@ -55,7 +46,7 @@ export declare class Component extends ReflectiveInjector implements JSXTypeof {
|
|
|
55
46
|
export interface LifeCycleCallback {
|
|
56
47
|
(): void | (() => void);
|
|
57
48
|
}
|
|
58
|
-
export interface PropsChangedCallback<T extends Props
|
|
49
|
+
export interface PropsChangedCallback<T extends Props> {
|
|
59
50
|
(currentProps: T | null, oldProps: T | null): void | (() => void);
|
|
60
51
|
}
|
|
61
52
|
/**
|
|
@@ -106,7 +97,7 @@ export declare function onUpdated(callback: LifeCycleCallback): () => void;
|
|
|
106
97
|
* }
|
|
107
98
|
* ```
|
|
108
99
|
*/
|
|
109
|
-
export declare function onPropsChanged<T extends Props
|
|
100
|
+
export declare function onPropsChanged<T extends Props>(callback: PropsChangedCallback<T>): () => void;
|
|
110
101
|
/**
|
|
111
102
|
* 当组件销毁时调用回调函数
|
|
112
103
|
* @param callback
|
|
@@ -115,9 +106,9 @@ export declare function onDestroy(callback: () => void): void;
|
|
|
115
106
|
export interface RefListener<T> {
|
|
116
107
|
(current: T): void | (() => void);
|
|
117
108
|
}
|
|
118
|
-
export type ExtractInstanceType<T, U = T extends (...args: any) => any ? ReturnType<T> : T> = U extends
|
|
109
|
+
export type ExtractInstanceType<T, U = T extends (...args: any) => any ? ReturnType<T> : T> = U extends JSXInternal.ComponentInstance<any> ? Omit<U, keyof JSXInternal.ComponentInstance<any>> : U extends Function ? never : T;
|
|
119
110
|
export interface AbstractInstanceType<T extends Record<string, any>> {
|
|
120
|
-
(): T &
|
|
111
|
+
(): T & JSXInternal.ComponentInstance<any>;
|
|
121
112
|
}
|
|
122
113
|
export declare class Ref<T, U> {
|
|
123
114
|
private callback;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import { JSXComponent
|
|
2
|
-
|
|
3
|
-
export interface Props
|
|
4
|
-
children?:
|
|
1
|
+
import { JSXComponent } from './component';
|
|
2
|
+
import { JSXInternal } from './types';
|
|
3
|
+
export interface Props {
|
|
4
|
+
children?: JSXInternal.JSXChildNode | JSXInternal.JSXChildNode[];
|
|
5
5
|
[key: string]: any;
|
|
6
6
|
[key: symbol]: any;
|
|
7
7
|
}
|
|
8
|
-
export declare
|
|
8
|
+
export declare function Fragment(props: Props): () => JSXInternal.JSXChildNode | JSXInternal.JSXChildNode[];
|
|
9
9
|
export type Key = number | string;
|
|
10
|
-
export declare function jsx
|
|
11
|
-
export declare function jsx
|
|
12
|
-
export declare
|
|
13
|
-
export declare function jsxs<T extends JSXChildNode[]>(setup: ComponentSetup, props: Props<T>, key?: Key): JSXComponent;
|
|
10
|
+
export declare function jsx(name: string, props: Props, key?: Key): JSXElement;
|
|
11
|
+
export declare function jsx(setup: JSXInternal.ElementClass, props: Props, key?: Key): JSXComponent;
|
|
12
|
+
export declare const jsxs: typeof jsx;
|
|
14
13
|
export interface JSXTypeof {
|
|
15
|
-
$$typeOf: string |
|
|
14
|
+
$$typeOf: string | JSXInternal.ElementClass;
|
|
16
15
|
is(target: JSXTypeof): boolean;
|
|
17
16
|
}
|
|
18
17
|
export declare class JSXText implements JSXTypeof {
|
|
@@ -27,10 +26,10 @@ export interface ListenDelegate {
|
|
|
27
26
|
}
|
|
28
27
|
export declare class JSXElement implements JSXTypeof {
|
|
29
28
|
type: string;
|
|
30
|
-
props: Props
|
|
29
|
+
props: Props;
|
|
31
30
|
key?: Key | undefined;
|
|
32
31
|
$$typeOf: string;
|
|
33
32
|
on?: Record<string, ListenDelegate>;
|
|
34
|
-
constructor(type: string, props: Props
|
|
33
|
+
constructor(type: string, props: Props, key?: Key | undefined);
|
|
35
34
|
is(target: JSXTypeof): boolean;
|
|
36
35
|
}
|
package/bundles/model/memo.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
(currentProps: T, prevProps: T): unknown;
|
|
5
|
-
}
|
|
6
|
-
export declare function withMemo<T extends Props = Props>(shouldUpdate: ShouldUpdate<T>, render: () => JSXChildNode): ComponentInstance<T>;
|
|
1
|
+
import { Props } from './jsx-element';
|
|
2
|
+
import { JSXInternal } from './types';
|
|
3
|
+
export declare function withMemo<T extends Props = Props>(shouldUpdate: JSXInternal.ComponentInstance<T>['$shouldUpdate'], render: () => JSXInternal.Element): JSXInternal.ComponentInstance<T>;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Subject } from '@tanbo/stream';
|
|
2
2
|
import { NullInjector } from '@tanbo/di';
|
|
3
|
-
import { Component
|
|
3
|
+
import { Component } from './component';
|
|
4
|
+
import { JSXInternal } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* Viewfly 根组件,用于实现组件状态更新事件通知
|
|
6
7
|
*/
|
|
7
8
|
export declare class RootComponent extends Component {
|
|
8
9
|
changeEmitter: Subject<void>;
|
|
9
|
-
constructor(factory:
|
|
10
|
+
constructor(factory: JSXInternal.ElementClass, parentInjector?: NullInjector);
|
|
10
11
|
markAsChanged(): void;
|
|
11
12
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Key, ExtractInstanceType, Ref } from './_api';
|
|
2
|
+
export declare namespace JSXInternal {
|
|
3
|
+
type ClassNames = string | Record<string, unknown> | Array<string | Record<string, unknown>>;
|
|
4
|
+
interface ComponentInstance<P> {
|
|
5
|
+
$render(): JSXChildNode;
|
|
6
|
+
$shouldUpdate?(currentProps: P, prevProps: P): boolean;
|
|
7
|
+
}
|
|
8
|
+
type JSXChildNode = Element | ElementClass | string | number | boolean | null | undefined | JSXChildNode[];
|
|
9
|
+
interface Element<P = any, C extends string | ElementClass<P> = string | ElementClass<P>> {
|
|
10
|
+
}
|
|
11
|
+
interface IntrinsicAttributes {
|
|
12
|
+
key?: Key;
|
|
13
|
+
ref?: any;
|
|
14
|
+
}
|
|
15
|
+
interface RefAttributes<T> extends IntrinsicAttributes {
|
|
16
|
+
ref?: Ref<T, ExtractInstanceType<T>> | Ref<T, ExtractInstanceType<T>>[];
|
|
17
|
+
}
|
|
18
|
+
interface ElementClass<P = any> {
|
|
19
|
+
(props: P): () => (JSXChildNode | ComponentInstance<P>);
|
|
20
|
+
}
|
|
21
|
+
interface ElementChildrenAttribute {
|
|
22
|
+
}
|
|
23
|
+
interface IntrinsicElements {
|
|
24
|
+
}
|
|
25
|
+
interface IntrinsicClassAttributes<T> extends RefAttributes<T> {
|
|
26
|
+
}
|
|
27
|
+
}
|
package/bundles/public-api.d.ts
CHANGED
package/bundles/viewfly.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Injector, Provider, ReflectiveInjector } from '@tanbo/di';
|
|
2
2
|
import { NativeNode } from './foundation/_api';
|
|
3
|
-
import {
|
|
4
|
-
export type RootNode = JSXElement | JSXComponent;
|
|
3
|
+
import { JSXInternal } from './model/_api';
|
|
5
4
|
/**
|
|
6
5
|
* Viewfly 配置项
|
|
7
6
|
*/
|
|
@@ -11,7 +10,7 @@ export interface Config {
|
|
|
11
10
|
/** 是否自动更新视图 */
|
|
12
11
|
autoUpdate?: boolean;
|
|
13
12
|
/** 根节点 */
|
|
14
|
-
root:
|
|
13
|
+
root: JSXInternal.JSXChildNode;
|
|
15
14
|
/** 根组件的上下文 */
|
|
16
15
|
context?: Injector;
|
|
17
16
|
}
|
package/jsx-runtime/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx, jsxs, Fragment,
|
|
1
|
+
import { jsx, jsxs, Fragment, JSXInternal } from '@viewfly/core';
|
|
2
2
|
import { NativeElements } from '@viewfly/platform-browser';
|
|
3
3
|
/**
|
|
4
4
|
* JSX namespace for usage with @jsxImportsSource directive
|
|
@@ -8,14 +8,16 @@ import { NativeElements } from '@viewfly/platform-browser';
|
|
|
8
8
|
declare const jsxDEV: typeof jsx;
|
|
9
9
|
export { jsx, jsxs, Fragment, jsxDEV };
|
|
10
10
|
export declare namespace JSX {
|
|
11
|
-
interface
|
|
11
|
+
interface Element extends JSXInternal.Element {
|
|
12
12
|
}
|
|
13
|
-
interface
|
|
13
|
+
interface ElementClass extends JSXInternal.ElementClass {
|
|
14
14
|
}
|
|
15
|
-
interface
|
|
15
|
+
interface IntrinsicElements extends NativeElements, JSXInternal.IntrinsicElements {
|
|
16
16
|
}
|
|
17
|
-
interface
|
|
17
|
+
interface IntrinsicAttributes extends JSXInternal.IntrinsicAttributes {
|
|
18
18
|
}
|
|
19
|
-
interface
|
|
19
|
+
interface ElementChildrenAttribute extends JSXInternal.ElementChildrenAttribute {
|
|
20
|
+
}
|
|
21
|
+
interface IntrinsicClassAttributes<T> extends JSXInternal.IntrinsicClassAttributes<T> {
|
|
20
22
|
}
|
|
21
23
|
}
|
package/jsx-runtime/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"build:lib": "rimraf index.esm.js index.js index.d.ts && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript && tsc index.ts -d"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@viewfly/core": "
|
|
10
|
-
"@viewfly/platform-browser": "
|
|
9
|
+
"@viewfly/core": "*",
|
|
10
|
+
"@viewfly/platform-browser": "*"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"@rollup/plugin-commonjs": "^25.0.3",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@viewfly/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
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",
|
|
@@ -23,8 +23,7 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript
|
|
27
|
-
"build:jsx": "cd jsx-runtime && npm run build:lib",
|
|
26
|
+
"build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
|
|
28
27
|
"publish:lib": "npm run build:lib && npm publish --access=public"
|
|
29
28
|
},
|
|
30
29
|
"license": "MIT",
|
|
@@ -52,5 +51,5 @@
|
|
|
52
51
|
"bugs": {
|
|
53
52
|
"url": "https://github.com/viewfly/viewfly.git/issues"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "993944f270a1a0abd095bcda0d9080c4bfebc655"
|
|
56
55
|
}
|
package/bundles/types.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Key, ExtractInstanceType, Ref, JSXComponent } from './model/_api';
|
|
2
|
-
export declare namespace ViewTypes {
|
|
3
|
-
type ClassNames = string | Record<string, unknown> | Array<string | Record<string, unknown>>;
|
|
4
|
-
interface IntrinsicAttributes {
|
|
5
|
-
key?: Key;
|
|
6
|
-
ref?: any;
|
|
7
|
-
}
|
|
8
|
-
interface RefAttributes<T> extends IntrinsicAttributes {
|
|
9
|
-
ref?: Ref<T, ExtractInstanceType<T>> | Ref<T, ExtractInstanceType<T>>[];
|
|
10
|
-
}
|
|
11
|
-
interface ElementClass extends JSXComponent {
|
|
12
|
-
}
|
|
13
|
-
interface ElementChildrenAttribute {
|
|
14
|
-
}
|
|
15
|
-
interface IntrinsicElements {
|
|
16
|
-
}
|
|
17
|
-
interface IntrinsicClassAttributes<T> extends IntrinsicAttributes {
|
|
18
|
-
}
|
|
19
|
-
}
|