@viewfly/core 1.0.0-alpha.2 → 1.0.0-alpha.21

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.
@@ -1,4 +1,4 @@
1
- import { jsx, jsxs, Fragment } from '@viewfly/core';
1
+ import { jsx, jsxs, Fragment, JSX as ViewflyJSX } from '@viewfly/core';
2
2
  /**
3
3
  * JSX namespace for usage with @jsxImportsSource directive
4
4
  * when ts compilerOptions.jsx is 'react-jsx'
@@ -7,15 +7,15 @@ import { jsx, jsxs, Fragment } from '@viewfly/core';
7
7
  declare const jsxDEV: typeof jsx;
8
8
  export { jsx, jsxs, Fragment, jsxDEV };
9
9
  export declare namespace JSX {
10
- type Element = JSXInternal.Element;
11
- interface ElementClass extends JSXInternal.ElementClass {
10
+ type Element = ViewflyJSX.Element;
11
+ interface ElementClass extends ViewflyJSX.ElementClass {
12
12
  }
13
- interface IntrinsicElements extends JSXInternal.IntrinsicElements {
13
+ interface IntrinsicElements extends ViewflyJSX.IntrinsicElements {
14
14
  }
15
- interface IntrinsicAttributes extends JSXInternal.IntrinsicAttributes {
15
+ interface IntrinsicAttributes extends ViewflyJSX.IntrinsicAttributes {
16
16
  }
17
- interface ElementChildrenAttribute extends JSXInternal.ElementChildrenAttribute {
17
+ interface ElementChildrenAttribute extends ViewflyJSX.ElementChildrenAttribute {
18
18
  }
19
- interface IntrinsicClassAttributes<T> extends JSXInternal.IntrinsicClassAttributes<T> {
19
+ interface IntrinsicClassAttributes<T> extends ViewflyJSX.IntrinsicClassAttributes<T> {
20
20
  }
21
21
  }
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@viewfly/core",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.21",
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
- "typings": "./bundles/public-api.d.ts",
7
+ "typings": "./bundles/index.d.ts",
8
8
  "exports": {
9
9
  ".": {
10
- "types": "./bundles/public-api.d.ts",
10
+ "types": "./bundles/index.d.ts",
11
11
  "import": "./bundles/index.esm.js",
12
12
  "require": "./bundles/index.js"
13
13
  },
@@ -23,7 +23,9 @@
23
23
  }
24
24
  },
25
25
  "scripts": {
26
- "build:lib": "rimraf bundles && rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
26
+ "build:lib": "rimraf bundles && npm run build && npm run build-d",
27
+ "build": "rollup --config rollup.config.ts --configPlugin @rollup/plugin-typescript",
28
+ "build-d": "rollup --config rollup-d.config.ts --configPlugin @rollup/plugin-typescript",
27
29
  "publish:lib": "npm run build:lib && npm publish --access=public"
28
30
  },
29
31
  "license": "MIT",
@@ -34,6 +36,7 @@
34
36
  "@rollup/plugin-typescript": "^11.1.2",
35
37
  "rimraf": "^3.0.2",
36
38
  "rollup": "^3.26.3",
39
+ "rollup-plugin-dts": "^6.1.1",
37
40
  "tslib": "^2.6.0"
38
41
  },
39
42
  "author": {
@@ -47,8 +50,8 @@
47
50
  "bugs": {
48
51
  "url": "https://github.com/viewfly/viewfly.git/issues"
49
52
  },
50
- "gitHead": "494829c8d0cde30d0a35c61351c863ea14515ac2",
53
+ "gitHead": "35403802377a499822c8801a48e68f85f9446563",
51
54
  "dependencies": {
52
- "reflect-metadata": "^0.1.13"
55
+ "reflect-metadata": "^0.2.2"
53
56
  }
54
57
  }
@@ -0,0 +1,14 @@
1
+ import dts from 'rollup-plugin-dts'
2
+
3
+ export default {
4
+ input: 'src/public-api.ts',
5
+ output: [
6
+ {
7
+ file: './bundles/index.d.ts',
8
+ format: 'es'
9
+ }
10
+ ],
11
+ plugins: [
12
+ dts(),
13
+ ]
14
+ }
@@ -1 +0,0 @@
1
- export declare function makeError(name: string): (message: string) => Error;
@@ -1,10 +0,0 @@
1
- export * from './forward-ref';
2
- export * from './injectable';
3
- export * from './injection-token';
4
- export * from './injector';
5
- export * from './metadata';
6
- export * from './null-injector';
7
- export * from './provider';
8
- export * from './reflective-injector';
9
- export * from './reflective-provider';
10
- export * from './type';
@@ -1,10 +0,0 @@
1
- export declare class ForwardRef<T = any> {
2
- private forwardRefFn;
3
- constructor(forwardRefFn: () => T);
4
- getRef(): T;
5
- }
6
- /**
7
- * 引用后声明的类的工具函数
8
- * @param fn
9
- */
10
- export declare function forwardRef<T>(fn: () => T): ForwardRef<T>;
@@ -1,20 +0,0 @@
1
- export declare class Scope {
2
- name: string;
3
- constructor(name: string);
4
- toString(): string;
5
- }
6
- export type ProvideScope = 'root' | Scope;
7
- export interface InjectableOptions {
8
- provideIn: ProvideScope;
9
- }
10
- export interface Injectable {
11
- provideIn?: ProvideScope;
12
- }
13
- export interface InjectableDecorator {
14
- (options?: InjectableOptions): ClassDecorator;
15
- new (options?: InjectableOptions): Injectable;
16
- }
17
- /**
18
- * 可注入类的装饰器
19
- */
20
- export declare const Injectable: InjectableDecorator;
@@ -1,8 +0,0 @@
1
- /**
2
- * 生成自定义依赖注入 token 的类
3
- */
4
- export declare class InjectionToken<T> {
5
- readonly description: string;
6
- constructor(description: string);
7
- toString(): string;
8
- }
@@ -1,26 +0,0 @@
1
- import { AbstractType, Type } from './type';
2
- import { InjectionToken } from './injection-token';
3
- /**
4
- * 查找规则
5
- */
6
- export declare enum InjectFlags {
7
- /** 默认查找规则 */
8
- Default = "Default",
9
- /** 锁定当前容器 */
10
- Self = "Self",
11
- /** 跳过当前容器 */
12
- SkipSelf = "SkipSelf",
13
- /** 可选查找 */
14
- Optional = "Optional"
15
- }
16
- /**
17
- * 根据 token 推断返回数据类型
18
- */
19
- export type ExtractValueType<T> = T extends Type<any> ? InstanceType<T> : T extends AbstractType<infer K> ? K : T extends InjectionToken<infer V> ? V : never;
20
- /**
21
- * DI 容器抽象基类
22
- */
23
- export declare abstract class Injector {
24
- abstract parentInjector: Injector | null;
25
- abstract get<T extends Type<any> | AbstractType<any> | InjectionToken<any>, U = never>(token: T, flags?: InjectFlags, notFoundValue?: U): ExtractValueType<T> | U;
26
- }
@@ -1,43 +0,0 @@
1
- import { AbstractType, Type } from './type';
2
- import { ExtractValueType, InjectFlags } from './injector';
3
- import { InjectionToken } from './injection-token';
4
- import { ForwardRef } from './forward-ref';
5
- export interface Inject {
6
- token: InjectionToken<any> | Type<any> | ForwardRef<InjectionToken<any> | Type<any>>;
7
- }
8
- export interface InjectDecorator {
9
- (token: InjectionToken<any> | Type<any> | ForwardRef<InjectionToken<any> | Type<any>>): ParameterDecorator;
10
- new (token: InjectionToken<any> | Type<any> | ForwardRef<InjectionToken<any> | Type<any>>): Inject;
11
- }
12
- /**
13
- * 构造函数参数装饰器,用于改变注入 token
14
- */
15
- export declare const Inject: InjectDecorator;
16
- export interface Self {
17
- }
18
- export interface SelfDecorator {
19
- (): ParameterDecorator;
20
- new (): Self;
21
- }
22
- export declare const Self: SelfDecorator;
23
- export interface SkipSelf {
24
- }
25
- export interface SkipSelfDecorator {
26
- (): ParameterDecorator;
27
- new (): SkipSelf;
28
- }
29
- export declare const SkipSelf: SkipSelfDecorator;
30
- export interface Optional {
31
- }
32
- export interface OptionalDecorator {
33
- (): ParameterDecorator;
34
- new (): Optional;
35
- }
36
- export declare const Optional: OptionalDecorator;
37
- export interface Prop {
38
- }
39
- export interface PropDecorator {
40
- <T extends Type<any> | AbstractType<any> | InjectionToken<any>, U = never>(token?: T | ForwardRef<ExtractValueType<T>>, flags?: InjectFlags, notFoundValue?: U): PropertyDecorator;
41
- new (token: any): Prop;
42
- }
43
- export declare const Prop: PropDecorator;
@@ -1,6 +0,0 @@
1
- import { InjectFlags, Injector } from './injector';
2
- export declare const THROW_IF_NOT_FOUND: any;
3
- export declare class NullInjector extends Injector {
4
- parentInjector: null;
5
- get(token: any, flag?: InjectFlags, notFoundValue?: any): any;
6
- }
@@ -1,30 +0,0 @@
1
- import { AbstractType, Type } from './type';
2
- import { InjectionToken } from './injection-token';
3
- export interface ClassProvider<T = any> {
4
- provide: Type<T> | AbstractType<T> | InjectionToken<T>;
5
- useClass: Type<T>;
6
- deps?: any[];
7
- }
8
- export interface FactoryProvider<T = any> {
9
- provide: Type<T> | AbstractType<T> | InjectionToken<T>;
10
- useFactory: (...args: any[]) => T;
11
- deps?: any[];
12
- }
13
- export interface ValueProvider<T = any> {
14
- provide: Type<T> | AbstractType<T> | InjectionToken<T>;
15
- useValue: T;
16
- }
17
- export interface ExistingProvider<T = any> {
18
- provide: Type<T> | AbstractType<T> | InjectionToken<T>;
19
- useExisting: T;
20
- }
21
- export interface ConstructorProvider<T = any> {
22
- provide: Type<T>;
23
- deps?: [];
24
- }
25
- export interface TypeProvider<T = any> extends Type<T> {
26
- }
27
- export interface AbstractProvider<T = any> extends AbstractType<T> {
28
- }
29
- export type StaticProvider<T = any> = ClassProvider<T> | FactoryProvider<T> | ValueProvider<T> | ExistingProvider<T> | ConstructorProvider<T>;
30
- export type Provider<T = any> = TypeProvider<T> | AbstractProvider<T> | StaticProvider<T>;
@@ -1,31 +0,0 @@
1
- import { Provider } from './provider';
2
- import { ExtractValueType, InjectFlags, Injector } from './injector';
3
- import { NormalizedProvider } from './reflective-provider';
4
- import { AbstractType, Type } from './type';
5
- import { InjectionToken } from './injection-token';
6
- import { Scope } from './injectable';
7
- /**
8
- * 反射注入器
9
- */
10
- export declare class ReflectiveInjector extends Injector {
11
- parentInjector: Injector | null;
12
- protected staticProviders: Provider[];
13
- protected scope?: Scope | undefined;
14
- protected normalizedProviders: NormalizedProvider[];
15
- protected recordValues: Map<Type<any> | AbstractType<any> | InjectionToken<any>, any>;
16
- constructor(parentInjector: Injector | null, staticProviders: Provider[], scope?: Scope | undefined);
17
- /**
18
- * 用于获取当前注入器上下文内的实例、对象或数据
19
- * @param token 访问 token
20
- * @param flags 查询规则
21
- * @param notFoundValue 如未查找到的返回值
22
- */
23
- get<T extends Type<any> | AbstractType<any> | InjectionToken<any>, U = never>(token: T, flags?: InjectFlags, notFoundValue?: U): ExtractValueType<T> | U;
24
- private getValue;
25
- /**
26
- * 解决并获取依赖参数
27
- * @param deps 依赖规则
28
- * @private
29
- */
30
- private resolveDeps;
31
- }
@@ -1,20 +0,0 @@
1
- import { Provider } from './provider';
2
- import { Injector } from './injector';
3
- import { Self, SkipSelf } from './metadata';
4
- import { ProvideScope } from './injectable';
5
- export interface ReflectiveDependency {
6
- injectKey: any;
7
- visibility: SkipSelf | Self | null;
8
- optional: boolean;
9
- }
10
- export interface NormalizedProvider {
11
- provide: any;
12
- generateFactory: (injector: Injector, cacheFn: (token: any, value: any) => void) => (...args: any[]) => any;
13
- deps: ReflectiveDependency[];
14
- scope: ProvideScope | null;
15
- }
16
- /**
17
- * 标准化 provide,并返回统一数据结构
18
- * @param provider
19
- */
20
- export declare function normalizeProvider(provider: Provider): NormalizedProvider;
@@ -1,7 +0,0 @@
1
- export declare const Type: FunctionConstructor;
2
- export interface Type<T> extends Function {
3
- new (...args: any[]): T;
4
- }
5
- export interface AbstractType<T> extends Function {
6
- prototype: T;
7
- }
@@ -1,3 +0,0 @@
1
- export * from './annotations';
2
- export * from './decorators';
3
- export * from './stringify';
@@ -1,33 +0,0 @@
1
- import { Injector } from '../injector';
2
- export interface ClassAnnotation {
3
- paramTypes: any[];
4
- metadata: any;
5
- }
6
- export interface ParamAnnotation {
7
- propertyKey: string | symbol;
8
- parameterIndex: number;
9
- metadata: any;
10
- }
11
- export interface PropertyDecoratorContextCallback {
12
- (instance: any, propertyName: string | symbol, token: any, injector: Injector): void;
13
- }
14
- export interface PropertyAnnotation {
15
- injectToken: any;
16
- propertyKey: string | symbol;
17
- contextCallback: PropertyDecoratorContextCallback;
18
- }
19
- /**
20
- * 用于保存 class 的元数据
21
- */
22
- export declare class Annotations {
23
- private classes;
24
- private props;
25
- private params;
26
- setClassMetadata(token: any, params: ClassAnnotation): void;
27
- getClassMetadata(token: any): ClassAnnotation | undefined;
28
- pushParamMetadata(token: any, params: ParamAnnotation): void;
29
- getParamMetadata(token: any): ParamAnnotation[] | undefined;
30
- getPropMetadataKeys(): any[];
31
- pushPropMetadata(token: any, params: PropertyAnnotation): void;
32
- getPropMetadata(token: any): PropertyAnnotation[] | undefined;
33
- }
@@ -1,17 +0,0 @@
1
- import { Annotations, PropertyDecoratorContextCallback } from './annotations';
2
- /**
3
- * 创建参数装饰器的工厂函数
4
- */
5
- export declare function makeParamDecorator(token: any, metadata: any): ParameterDecorator;
6
- /**
7
- * 创建属性装饰器的工厂函数
8
- */
9
- export declare function makePropertyDecorator(token: any, injectToken: any, contextCallback: PropertyDecoratorContextCallback): PropertyDecorator;
10
- /**
11
- * 创建类装饰器的工厂函数
12
- */
13
- export declare function makeClassDecorator(token: any, metadata: any): ClassDecorator;
14
- /**
15
- * 获取类注解的工具函数
16
- */
17
- export declare function getAnnotations(target: any): Annotations;
@@ -1 +0,0 @@
1
- export declare function stringify(token: any): string;
@@ -1,8 +0,0 @@
1
- export * from './component';
2
- export * from './injection-tokens';
3
- export * from './jsx-element';
4
- export * from './memo';
5
- export * from './renderer';
6
- export * from './root.component';
7
- export * from './types';
8
- export { Atom, ComponentView } from './_utils';
@@ -1,52 +0,0 @@
1
- import { JSXNode } from './jsx-element';
2
- import { NativeNode } from './injection-tokens';
3
- import { Component } from './component';
4
- export interface ListenDelegate {
5
- delegate: () => any;
6
- listenFn: ((...args: any[]) => any) | void;
7
- }
8
- export interface ObjectChanges {
9
- remove: [string, any][];
10
- add: [string, any][];
11
- replace: [string, any, any][];
12
- }
13
- export declare const refKey = "ref";
14
- export declare function getObjectChanges(newProps: Record<string, any>, oldProps: Record<string, any>): ObjectChanges;
15
- export interface ArrayChanges<T> {
16
- remove: T[];
17
- add: T[];
18
- }
19
- export declare function getArrayChanges<T>(left: T[], right: T[]): ArrayChanges<T>;
20
- export declare function classToString(config: unknown): string;
21
- export declare function styleToObject(style: string | Record<string, any>): Record<string, any>;
22
- export interface TextAtom {
23
- type: 'text';
24
- jsxNode: string;
25
- nativeNode: NativeNode | null;
26
- child: Atom | null;
27
- sibling: Atom | null;
28
- isSvg: boolean;
29
- }
30
- export interface ElementAtom {
31
- type: 'element';
32
- jsxNode: JSXNode<string>;
33
- nativeNode: NativeNode | null;
34
- child: Atom | null;
35
- sibling: Atom | null;
36
- isSvg: boolean;
37
- }
38
- export interface ComponentAtom {
39
- type: 'component';
40
- jsxNode: JSXNode<JSXInternal.ComponentSetup> | Component;
41
- nativeNode: NativeNode | null;
42
- child: Atom | null;
43
- sibling: Atom | null;
44
- isSvg: boolean;
45
- }
46
- export type Atom = TextAtom | ElementAtom | ComponentAtom;
47
- export interface ComponentView {
48
- atom: Atom;
49
- host: NativeNode;
50
- isParent: boolean;
51
- rootHost: NativeNode;
52
- }