@viewfly/core 0.0.1 → 0.0.3

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.
@@ -58,8 +58,12 @@ function getSignalDepsContext() {
58
58
  return signalDepsStack[signalDepsStack.length - 1];
59
59
  }
60
60
  class JSXComponent {
61
- constructor(createInstance) {
62
- this.createInstance = createInstance;
61
+ constructor(props, factory) {
62
+ this.props = props;
63
+ this.factory = factory;
64
+ }
65
+ createInstance(injector) {
66
+ return this.factory(injector, this.props);
63
67
  }
64
68
  }
65
69
  /**
@@ -473,20 +477,20 @@ const Fragment = function Fragment(props) {
473
477
  return props.children;
474
478
  };
475
479
  };
476
- function jsx(setup, config, key) {
480
+ function jsx(setup, props, key) {
477
481
  if (typeof setup === 'string') {
478
- return new JSXElement(setup, config, key);
482
+ return new JSXElement(setup, props, key);
479
483
  }
480
- return new JSXComponent(function (context) {
481
- return new Component(context, setup, config, key);
484
+ return new JSXComponent(props, function (context, props) {
485
+ return new Component(context, setup, props, key);
482
486
  });
483
487
  }
484
- function jsxs(setup, config, key) {
488
+ function jsxs(setup, props, key) {
485
489
  if (typeof setup === 'string') {
486
- return new JSXElement(setup, config, key);
490
+ return new JSXElement(setup, props, key);
487
491
  }
488
- return new JSXComponent(function (context) {
489
- return new Component(context, setup, config, key);
492
+ return new JSXComponent(props, function (context, props) {
493
+ return new Component(context, setup, props, key);
490
494
  });
491
495
  }
492
496
  class JSXText {
package/bundles/index.js CHANGED
@@ -59,8 +59,12 @@ function getSignalDepsContext() {
59
59
  return signalDepsStack[signalDepsStack.length - 1];
60
60
  }
61
61
  class JSXComponent {
62
- constructor(createInstance) {
63
- this.createInstance = createInstance;
62
+ constructor(props, factory) {
63
+ this.props = props;
64
+ this.factory = factory;
65
+ }
66
+ createInstance(injector) {
67
+ return this.factory(injector, this.props);
64
68
  }
65
69
  }
66
70
  /**
@@ -474,20 +478,20 @@ const Fragment = function Fragment(props) {
474
478
  return props.children;
475
479
  };
476
480
  };
477
- function jsx(setup, config, key) {
481
+ function jsx(setup, props, key) {
478
482
  if (typeof setup === 'string') {
479
- return new JSXElement(setup, config, key);
483
+ return new JSXElement(setup, props, key);
480
484
  }
481
- return new JSXComponent(function (context) {
482
- return new Component(context, setup, config, key);
485
+ return new JSXComponent(props, function (context, props) {
486
+ return new Component(context, setup, props, key);
483
487
  });
484
488
  }
485
- function jsxs(setup, config, key) {
489
+ function jsxs(setup, props, key) {
486
490
  if (typeof setup === 'string') {
487
- return new JSXElement(setup, config, key);
491
+ return new JSXElement(setup, props, key);
488
492
  }
489
- return new JSXComponent(function (context) {
490
- return new Component(context, setup, config, key);
493
+ return new JSXComponent(props, function (context, props) {
494
+ return new Component(context, setup, props, key);
491
495
  });
492
496
  }
493
497
  class JSXText {
package/bundles/jsx.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { Key, Ref } from '@viewfly/core';
2
2
  export declare namespace JSX {
3
+ type ClassNames = string | Record<string, unknown> | Array<string | Record<string, unknown>>;
3
4
  interface Attributes<T extends object> {
4
5
  ref?: Ref<T> | Ref<T>[];
5
6
  key?: Key;
@@ -1,8 +1,10 @@
1
1
  import { Provider, ReflectiveInjector, AbstractType, Type, InjectionToken, InjectFlags, Injector } from '@tanbo/di';
2
2
  import { Props, Key, JSXTypeof, JSXChildNode } from './jsx-element';
3
3
  export declare class JSXComponent {
4
- createInstance: (injector: Component) => Component;
5
- constructor(createInstance: (injector: Component) => Component);
4
+ props: Props;
5
+ private factory;
6
+ constructor(props: Props, factory: (injector: Component, props: Props) => Component);
7
+ createInstance(injector: Component): Component;
6
8
  }
7
9
  export interface ComponentSetup<T extends Props<any> = Props<any>> {
8
10
  (props?: T): () => JSXChildNode;
@@ -7,10 +7,10 @@ export interface Props<T = JSXChildNode | JSXChildNode[]> {
7
7
  }
8
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: 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;
10
+ export declare function jsx<T extends JSXChildNode>(name: string, props: Props<T>, key?: Key): JSXElement;
11
+ export declare function jsx<T extends JSXChildNode>(setup: ComponentSetup, props: Props<T>, key?: Key): JSXComponent;
12
+ export declare function jsxs<T extends JSXChildNode[]>(name: string, props: Props<T>, key?: Key): JSXElement;
13
+ export declare function jsxs<T extends JSXChildNode[]>(setup: ComponentSetup, props: Props<T>, key?: Key): JSXComponent;
14
14
  export interface JSXTypeof {
15
15
  $$typeOf: string | ComponentSetup;
16
16
  is(target: JSXTypeof): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@viewfly/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
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",
@@ -34,5 +34,5 @@
34
34
  "bugs": {
35
35
  "url": "https://github.com/viewfly/viewfly.git/issues"
36
36
  },
37
- "gitHead": "13f2af4215a1cd85af544af55744b2635e5cbf1b"
37
+ "gitHead": "55152a4c7db778d22e4ed1d8cd648f9800a01992"
38
38
  }