@viewfly/core 1.0.0-alpha.15 → 1.0.0-alpha.16

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.
@@ -191,6 +191,22 @@ declare class ReflectiveInjector implements Injector {
191
191
 
192
192
  declare function makeError(name: string): (message: string) => Error;
193
193
 
194
+ interface Props {
195
+ children?: JSXNode | JSXNode[];
196
+ }
197
+ declare function Fragment(props: Props): () => any;
198
+ type Key = number | string;
199
+ declare function jsx(type: string | ComponentSetup, props: Props & Record<string, any>, key?: Key): ViewFlyNode;
200
+ declare const jsxs: typeof jsx;
201
+ interface ViewFlyNode<T = string | ComponentSetup> {
202
+ type: T;
203
+ props: Props & Record<string, any>;
204
+ key?: Key;
205
+ }
206
+ declare const JSXNodeFactory: {
207
+ createNode<T = string | ComponentSetup<any>>(type: T, props: Props & Record<string, any>, key?: Key): ViewFlyNode<T>;
208
+ };
209
+
194
210
  type NativeNode = Record<string, any>;
195
211
  declare abstract class NativeRenderer<ElementNode = NativeNode, TextNode = NativeNode> {
196
212
  abstract createElement(name: string, isSvg: boolean): ElementNode;
@@ -210,32 +226,52 @@ declare abstract class NativeRenderer<ElementNode = NativeNode, TextNode = Nativ
210
226
  abstract insertAfter(newNode: ElementNode | TextNode, ref: ElementNode | TextNode, isSvg: boolean): void;
211
227
  }
212
228
 
213
- interface Props {
214
- children?: JSXInternal.ViewNode | JSXInternal.ViewNode[];
215
- }
216
- declare function Fragment(props: Props): () => any;
217
- type Key = number | string;
218
- declare function jsx(type: string | JSXInternal.ComponentSetup, props: Props & Record<string, any>, key?: Key): JSXNode;
219
- declare const jsxs: typeof jsx;
220
- interface JSXNode<T = string | JSXInternal.ComponentSetup> {
221
- type: T;
222
- props: Props & Record<string, any>;
223
- key?: Key;
229
+ declare namespace JSX {
230
+ type Element<P = any> = IntrinsicElements[string] | ComponentSetup<P>;
231
+ interface IntrinsicAttributes {
232
+ key?: Key;
233
+ ref?: any;
234
+ }
235
+ interface RefAttributes<T> extends IntrinsicAttributes {
236
+ ref?: DynamicRef<ExtractInstanceType<T>> | DynamicRef<ExtractInstanceType<T>>[];
237
+ }
238
+ interface ElementClass<P = any> extends ComponentInstance<P> {
239
+ }
240
+ interface ElementChildrenAttribute {
241
+ }
242
+ interface IntrinsicElements {
243
+ [name: string]: any;
244
+ }
245
+ interface IntrinsicClassAttributes<T> {
246
+ ref?: DynamicRef<T>;
247
+ }
224
248
  }
225
- declare const JSXNodeFactory: {
226
- createNode<T = string | JSXInternal.ComponentSetup<any>>(type: T, props: Props & Record<string, any>, key?: Key): JSXNode<T>;
227
- };
228
249
 
250
+ type ClassNames = string | Record<string, unknown> | false | null | undefined | ClassNames[];
251
+ interface ComponentInstance<P> {
252
+ $portalHost?: NativeNode;
253
+ $render(): JSXNode;
254
+ $useMemo?(currentProps: P, prevProps: P): boolean;
255
+ }
256
+ type JSXNode = JSX.Element | JSX.ElementClass | string | number | boolean | null | undefined | Iterable<JSXNode>;
257
+ interface ComponentAnnotation {
258
+ scope?: Scope;
259
+ providers?: Provider[];
260
+ }
261
+ interface ComponentSetup<P = any> {
262
+ (props: P): (() => JSXNode) | ComponentInstance<P>;
263
+ annotation?: ComponentAnnotation;
264
+ }
229
265
  /**
230
266
  * Viewfly 组件管理类,用于管理组件的生命周期,上下文等
231
267
  */
232
268
  declare class Component extends ReflectiveInjector {
233
269
  private readonly parentComponent;
234
- readonly type: JSXInternal.ComponentSetup;
270
+ readonly type: ComponentSetup;
235
271
  props: Props;
236
272
  readonly key?: Key | undefined;
237
- instance: JSXInternal.ComponentInstance<Props>;
238
- template: JSXInternal.ViewNode;
273
+ instance: ComponentInstance<Props>;
274
+ template: JSXNode;
239
275
  changedSubComponents: Set<Component>;
240
276
  get dirty(): boolean;
241
277
  get changed(): boolean;
@@ -250,7 +286,7 @@ declare class Component extends ReflectiveInjector {
250
286
  private unWatch?;
251
287
  private isFirstRendering;
252
288
  private refs;
253
- constructor(parentComponent: Injector | null, type: JSXInternal.ComponentSetup, props: Props, key?: Key | undefined);
289
+ constructor(parentComponent: Injector | null, type: ComponentSetup, props: Props, key?: Key | undefined);
254
290
  markAsDirtied(): void;
255
291
  markAsChanged(changedComponent?: Component): void;
256
292
  render(): {
@@ -328,9 +364,9 @@ declare function onUnmounted(callback: () => void): void;
328
364
  interface RefListener<T> {
329
365
  (current: T): void | (() => void);
330
366
  }
331
- 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;
367
+ type ExtractInstanceType<T, U = T extends (...args: any) => any ? ReturnType<T> : T> = U extends ComponentInstance<any> ? Omit<U, keyof ComponentInstance<any>> : U extends Function ? never : T;
332
368
  interface AbstractInstanceType<T extends Record<string, any>> {
333
- (): T & JSXInternal.ComponentInstance<any>;
369
+ (): T & ComponentInstance<any>;
334
370
  }
335
371
  declare class DynamicRef<T> {
336
372
  private callback;
@@ -457,7 +493,7 @@ declare function watch<T = any>(deps: Signal<any>[], callback: WatchCallback<T[]
457
493
  * })
458
494
  * ```
459
495
  */
460
- declare function withAnnotation<T extends JSXInternal.ComponentSetup>(annotation: JSXInternal.ComponentAnnotation, componentSetup: T): T;
496
+ declare function withAnnotation<T extends ComponentSetup>(annotation: ComponentAnnotation, componentSetup: T): T;
461
497
  /**
462
498
  * 通过组件上下文获取 IoC 容器内数据的勾子方法
463
499
  */
@@ -467,7 +503,7 @@ declare function inject<T extends Type<any> | AbstractType<any> | InjectionToken
467
503
  */
468
504
  declare function getCurrentInstance(): Component;
469
505
 
470
- declare function withMemo<T extends Props = Props>(canUseMemo: JSXInternal.ComponentInstance<T>['$useMemo'], render: () => JSXInternal.ViewNode): JSXInternal.ComponentInstance<T>;
506
+ declare function withMemo<T extends Props = Props>(canUseMemo: ComponentInstance<T>['$useMemo'], render: () => JSXNode): ComponentInstance<T>;
471
507
 
472
508
  declare function createRenderer(component: Component, nativeRenderer: NativeRenderer): (host: NativeNode) => void;
473
509
 
@@ -476,49 +512,10 @@ declare function createRenderer(component: Component, nativeRenderer: NativeRend
476
512
  */
477
513
  declare class RootComponent extends Component {
478
514
  private refresh;
479
- constructor(parentInjector: Injector | null, factory: JSXInternal.ComponentSetup, refresh: () => void);
515
+ constructor(parentInjector: Injector | null, factory: ComponentSetup, refresh: () => void);
480
516
  markAsChanged(changedComponent?: Component): void;
481
517
  }
482
518
 
483
- type ViewNode = JSXInternal.ViewNode;
484
- declare global {
485
- namespace JSXInternal {
486
- type ClassNames = string | Record<string, unknown> | false | null | undefined | ClassNames[];
487
- interface ComponentInstance<P> {
488
- $portalHost?: NativeNode;
489
- $render(): ViewNode;
490
- $useMemo?(currentProps: P, prevProps: P): boolean;
491
- }
492
- type ViewNode = Element | JSXInternal.ElementClass | string | number | boolean | null | undefined | Iterable<ViewNode>;
493
- interface ComponentAnnotation {
494
- scope?: Scope;
495
- providers?: Provider[];
496
- }
497
- interface ComponentSetup<P = any> {
498
- (props: P): (() => ViewNode) | ComponentInstance<P>;
499
- annotation?: ComponentAnnotation;
500
- }
501
- type Element<P = any, C extends string | ComponentSetup<P> = string | ComponentSetup<P>> = C extends string ? IntrinsicElements[C] : (() => Element) | ComponentInstance<P>;
502
- interface IntrinsicAttributes {
503
- key?: Key;
504
- ref?: any;
505
- }
506
- interface RefAttributes<T> extends IntrinsicAttributes {
507
- ref?: DynamicRef<ExtractInstanceType<T>> | DynamicRef<ExtractInstanceType<T>>[];
508
- }
509
- interface ElementClass<P = any> extends ComponentInstance<P> {
510
- }
511
- interface ElementChildrenAttribute {
512
- }
513
- interface IntrinsicElements {
514
- [name: string]: any;
515
- }
516
- interface IntrinsicClassAttributes<T> {
517
- ref?: DynamicRef<T>;
518
- }
519
- }
520
- }
521
-
522
519
  declare const TextAtomType: unique symbol;
523
520
  declare const ElementAtomType: unique symbol;
524
521
  declare const ComponentAtomType: unique symbol;
@@ -534,7 +531,7 @@ interface TextAtom {
534
531
  interface ElementAtom {
535
532
  type: typeof ElementAtomType;
536
533
  index: number;
537
- jsxNode: JSXNode<string>;
534
+ jsxNode: ViewFlyNode<string>;
538
535
  nativeNode: NativeNode | null;
539
536
  child: Atom | null;
540
537
  sibling: Atom | null;
@@ -543,7 +540,7 @@ interface ElementAtom {
543
540
  interface ComponentAtom {
544
541
  type: typeof ComponentAtomType;
545
542
  index: number;
546
- jsxNode: JSXNode<JSXInternal.ComponentSetup> | Component;
543
+ jsxNode: ViewFlyNode<ComponentSetup> | Component;
547
544
  nativeNode: NativeNode | null;
548
545
  child: Atom | null;
549
546
  sibling: Atom | null;
@@ -562,7 +559,7 @@ interface ComponentView {
562
559
  */
563
560
  interface Config {
564
561
  /** 根节点 */
565
- root: JSXInternal.ViewNode;
562
+ root: JSXNode;
566
563
  /** 平台渲染器 */
567
564
  nativeRenderer: NativeRenderer;
568
565
  /** 应用的上下文 */
@@ -584,4 +581,4 @@ interface Module {
584
581
  }
585
582
  declare function viewfly<T extends NativeNode>(config: Config): Application<T>;
586
583
 
587
- export { type AbstractInstanceType, type AbstractProvider, type AbstractType, type Application, type Atom, type ClassProvider, Component, type ComponentView, type Config, type ConstructorProvider, DynamicRef, type ExistingProvider, type ExtractInstanceType, type ExtractValueType, type FactoryProvider, ForwardRef, Fragment, Inject, type InjectDecorator, InjectFlags, Injectable, type InjectableDecorator, type InjectableOptions, InjectionToken, Injector, type JSXNode, JSXNodeFactory, type Key, type LifeCycleCallback, type Module, type NativeNode, NativeRenderer, type NormalizedProvider, NullInjector, Optional, type OptionalDecorator, Prop, type PropDecorator, type Props, type PropsChangedCallback, type ProvideScope, type Provider, type RefListener, type ReflectiveDependency, ReflectiveInjector, RootComponent, Scope, Self, type SelfDecorator, type Signal, SkipSelf, type SkipSelfDecorator, type StaticProvider, StaticRef, THROW_IF_NOT_FOUND, Type, type TypeProvider, type ValueProvider, type ViewNode, type WatchCallback, createDerived, createDynamicRef, createRef, createRenderer, createSignal, forwardRef, getCurrentInstance, inject, jsx, jsxs, makeError, normalizeProvider, onMounted, onPropsChanged, onUnmounted, onUpdated, viewfly, watch, withAnnotation, withMemo };
584
+ export { type AbstractInstanceType, type AbstractProvider, type AbstractType, type Application, type Atom, type ClassNames, type ClassProvider, Component, type ComponentAnnotation, type ComponentInstance, type ComponentSetup, type ComponentView, type Config, type ConstructorProvider, DynamicRef, type ExistingProvider, type ExtractInstanceType, type ExtractValueType, type FactoryProvider, ForwardRef, Fragment, Inject, type InjectDecorator, InjectFlags, Injectable, type InjectableDecorator, type InjectableOptions, InjectionToken, Injector, JSX, type JSXNode, JSXNodeFactory, type Key, type LifeCycleCallback, type Module, type NativeNode, NativeRenderer, type NormalizedProvider, NullInjector, Optional, type OptionalDecorator, Prop, type PropDecorator, type Props, type PropsChangedCallback, type ProvideScope, type Provider, type RefListener, type ReflectiveDependency, ReflectiveInjector, RootComponent, Scope, Self, type SelfDecorator, type Signal, SkipSelf, type SkipSelfDecorator, type StaticProvider, StaticRef, THROW_IF_NOT_FOUND, Type, type TypeProvider, type ValueProvider, type ViewFlyNode, type WatchCallback, createDerived, createDynamicRef, createRef, createRenderer, createSignal, forwardRef, getCurrentInstance, inject, jsx, jsxs, makeError, normalizeProvider, onMounted, onPropsChanged, onUnmounted, onUpdated, viewfly, watch, withAnnotation, withMemo };
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/core",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.16",
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",
@@ -50,7 +50,7 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/viewfly/viewfly.git/issues"
52
52
  },
53
- "gitHead": "20910725ab3302fe98b04db6e6f6b44a3f5b64b5",
53
+ "gitHead": "d2c8ce1c906fd80e05e27d677e7f678ccae0e9a1",
54
54
  "dependencies": {
55
55
  "reflect-metadata": "^0.2.2"
56
56
  }