nesquick 1.4.0 → 2.0.0

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/lib/For/For.js CHANGED
@@ -85,7 +85,7 @@ function For(props) {
85
85
  const map = getCycleMap(props);
86
86
  (0, State_1.useRender)(() => {
87
87
  cycle = !cycle;
88
- const each = props.each().slice();
88
+ const each = props.each.slice();
89
89
  if (children.length === 0) {
90
90
  for (let i = 0; i < each.length; i++) {
91
91
  const item = each[i];
package/lib/For/getMap.js CHANGED
@@ -2,12 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMap = getMap;
4
4
  function getMap(props) {
5
- if ("ids" in props && props.ids) {
5
+ const idsCallback = "ids" in props && props.ids;
6
+ if (idsCallback) {
6
7
  const childrenMap = new Map();
7
8
  let idLength = 0;
8
9
  return {
9
10
  getId(item, i) {
10
- const ids = props.ids(item, i);
11
+ const ids = idsCallback(item, i);
11
12
  if (!ids || ids.length === 0) {
12
13
  throw new Error(`Invalid ids array length. ids() should not return an empty array`);
13
14
  }
@@ -77,8 +78,9 @@ function getMap(props) {
77
78
  }
78
79
  else {
79
80
  const childrenMap = new Map();
81
+ const idCallback = "id" in props && props.id || (item => item);
80
82
  return {
81
- getId: ("id" in props && props.id) || (item => item),
83
+ getId: idCallback,
82
84
  equalsId(a, b) {
83
85
  return a === b;
84
86
  },
@@ -21,6 +21,17 @@ function getAttributeNs(attributes, k) {
21
21
  }
22
22
  return null;
23
23
  }
24
+ function getterFromFunctions(props) {
25
+ const res = Object.create(null);
26
+ for (const k in props) {
27
+ Object.defineProperty(res, k, {
28
+ get() {
29
+ return props[k]();
30
+ }
31
+ });
32
+ }
33
+ return res;
34
+ }
24
35
  class NesquickComponent {
25
36
  constructor(_render, props) {
26
37
  this._render = _render;
@@ -29,11 +40,11 @@ class NesquickComponent {
29
40
  this._styleSubscriptions = null;
30
41
  this._xmlns = null;
31
42
  this._children = [];
32
- this.props = props;
33
43
  }
34
44
  render(document) {
35
45
  State_1.subscriptions.set(this._subscriptions);
36
46
  if (typeof this._render === "function") {
47
+ this.props = getterFromFunctions(this.props);
37
48
  const element = this._render(this.props);
38
49
  if (this._xmlns) {
39
50
  element.setXmlns(this._xmlns);
@@ -4,9 +4,7 @@ exports.NesquickFragment = void 0;
4
4
  const NesquickComponent_1 = require("./NesquickComponent");
5
5
  class NesquickFragment extends NesquickComponent_1.NesquickComponent {
6
6
  constructor(children) {
7
- super("", {
8
- children: children != null ? Array.isArray(children) ? children : [children] : []
9
- });
7
+ super("", { children });
10
8
  this._lastNode = null;
11
9
  this._fragment = null;
12
10
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transformer = void 0;
4
- exports.createCheckFunction = createCheckFunction;
5
4
  const TS = require("typescript");
6
5
  function getSingleIdentifier(node) {
7
6
  let identifier = null;
@@ -25,49 +24,65 @@ function getSingleBody(node) {
25
24
  });
26
25
  return body;
27
26
  }
28
- function createCheckFunction(fName) {
29
- return TS.factory.createFunctionDeclaration(void 0, void 0, fName, void 0, [TS.factory.createParameterDeclaration(void 0, void 0, TS.factory.createIdentifier("v"))], void 0, TS.factory.createBlock([
30
- TS.factory.createReturnStatement(TS.factory.createConditionalExpression(TS.factory.createBinaryExpression(TS.factory.createTypeOfExpression(TS.factory.createIdentifier("v")), TS.factory.createToken(TS.SyntaxKind.EqualsEqualsEqualsToken), TS.factory.createStringLiteral("function")), TS.factory.createToken(TS.SyntaxKind.QuestionToken), TS.factory.createIdentifier("v"), TS.factory.createToken(TS.SyntaxKind.ColonToken), TS.factory.createArrowFunction(void 0, void 0, [], void 0, TS.factory.createToken(TS.SyntaxKind.EqualsGreaterThanToken), TS.factory.createIdentifier("v"))))
31
- ]));
27
+ function createSpreadCheckFunction(fName) {
28
+ const obj = TS.factory.createIdentifier("obj");
29
+ const check = TS.factory.createIdentifier("check");
30
+ const res = TS.factory.createIdentifier("res");
31
+ const k = TS.factory.createIdentifier("k");
32
+ const v = TS.factory.createIdentifier("v");
33
+ return TS.factory.createFunctionDeclaration(void 0, void 0, fName, void 0, [
34
+ TS.factory.createParameterDeclaration(void 0, void 0, obj),
35
+ TS.factory.createParameterDeclaration(void 0, void 0, check)
36
+ ], void 0, TS.factory.createBlock([
37
+ TS.factory.createVariableStatement(void 0, TS.factory.createVariableDeclarationList([
38
+ TS.factory.createVariableDeclaration(res, void 0, void 0, TS.factory.createCallExpression(TS.factory.createPropertyAccessExpression(TS.factory.createIdentifier("Object"), "create"), void 0, [TS.factory.createNull()]))
39
+ ], TS.NodeFlags.Const)),
40
+ TS.factory.createForInStatement(TS.factory.createVariableDeclarationList([TS.factory.createVariableDeclaration(k)], TS.NodeFlags.Const), obj, TS.factory.createBlock([
41
+ TS.factory.createVariableStatement(void 0, TS.factory.createVariableDeclarationList([
42
+ TS.factory.createVariableDeclaration(v, void 0, void 0, TS.factory.createElementAccessExpression(obj, k))
43
+ ], TS.NodeFlags.Const)),
44
+ TS.factory.createIfStatement(TS.factory.createBinaryExpression(TS.factory.createPrefixUnaryExpression(TS.SyntaxKind.ExclamationToken, check), TS.factory.createToken(TS.SyntaxKind.BarBarToken), TS.factory.createBinaryExpression(TS.factory.createTypeOfExpression(v), TS.factory.createToken(TS.SyntaxKind.ExclamationEqualsEqualsToken), TS.factory.createStringLiteral("function"))), TS.factory.createBlock([
45
+ TS.factory.createExpressionStatement(TS.factory.createBinaryExpression(TS.factory.createElementAccessExpression(res, k), TS.factory.createToken(TS.SyntaxKind.EqualsToken), TS.factory.createArrowFunction(void 0, void 0, [], void 0, TS.factory.createToken(TS.SyntaxKind.EqualsGreaterThanToken), v)))
46
+ ], true), TS.factory.createBlock([
47
+ TS.factory.createExpressionStatement(TS.factory.createBinaryExpression(TS.factory.createElementAccessExpression(res, k), TS.factory.createToken(TS.SyntaxKind.EqualsToken), v))
48
+ ], true))
49
+ ], true)),
50
+ TS.factory.createReturnStatement(res)
51
+ ], true));
32
52
  }
33
53
  const transformer = context => {
34
54
  return sourceFile => {
35
- let hasChecker = false;
36
- const checkerName = TS.factory.createUniqueName("_check");
55
+ let hasSpreadChecker = false;
56
+ const spreadCheckerName = TS.factory.createUniqueName("_spread");
57
+ const processNode = (node, options) => {
58
+ let hasCallExpression = false;
59
+ node = TS.visitEachChild(node, node => {
60
+ const res = visitGeneric(node, options);
61
+ hasCallExpression = hasCallExpression || res.hasCallExpression;
62
+ return res.node;
63
+ }, context);
64
+ return { node, hasCallExpression };
65
+ };
37
66
  const visitGeneric = (node, options) => {
38
- let hasSpread = options.userComponent && TS.isJsxSpreadAttribute(node);
39
67
  let hasCallExpression = TS.isCallExpression(node);
40
- if (TS.isJsxOpeningLikeElement(node)) {
68
+ if (TS.isJsxSpreadAttribute(node)) {
69
+ hasSpreadChecker = true;
70
+ const expression = visitGeneric(node.expression, {}).node;
71
+ if (TS.isExpression(expression)) {
72
+ const callExpression = TS.factory.createCallExpression(spreadCheckerName, void 0, [expression, options.userComponent ? TS.factory.createFalse() : TS.factory.createTrue()]);
73
+ node = TS.factory.updateJsxSpreadAttribute(node, callExpression);
74
+ }
75
+ }
76
+ else if (TS.isJsxOpeningLikeElement(node)) {
41
77
  const firstLetter = node.tagName.getText()[0];
42
78
  const userComponent = firstLetter !== firstLetter.toLowerCase();
43
- node = TS.visitEachChild(node, node => {
44
- const res = visitGeneric(node, { userComponent });
45
- hasSpread = hasSpread || res.hasSpread;
46
- hasCallExpression = hasCallExpression || res.hasCallExpression;
47
- return res.node;
48
- }, context);
49
- if (userComponent && hasSpread) {
50
- const symbol = TS.factory.createCallExpression(TS.factory.createPropertyAccessExpression(TS.factory.createIdentifier("Symbol"), "for"), void 0, [TS.factory.createStringLiteral("$nesquickSpreadProps")]);
51
- if (TS.isJsxOpeningLikeElement(node)) {
52
- const attributes = TS.factory.updateJsxAttributes(node.attributes, [
53
- ...node.attributes.properties,
54
- TS.factory.createJsxSpreadAttribute(TS.factory.createObjectLiteralExpression([
55
- TS.factory.createPropertyAssignment(TS.factory.createComputedPropertyName(symbol), TS.factory.createTrue())
56
- ]))
57
- ]);
58
- if (TS.isJsxOpeningElement(node)) {
59
- node = TS.factory.updateJsxOpeningElement(node, node.tagName, node.typeArguments, attributes);
60
- }
61
- else if (TS.isJsxSelfClosingElement(node)) {
62
- node = TS.factory.updateJsxSelfClosingElement(node, node.tagName, node.typeArguments, attributes);
63
- }
64
- }
65
- }
79
+ const res = processNode(node, { userComponent });
80
+ node = res.node;
81
+ hasCallExpression = hasCallExpression || res.hasCallExpression;
66
82
  }
67
83
  else if (TS.isJsxAttribute(node)) {
68
84
  node = TS.visitEachChild(node, node => {
69
85
  const res = visitGeneric(node, { ...options, isJsxAttribute: true });
70
- hasSpread = hasSpread || res.hasSpread;
71
86
  hasCallExpression = hasCallExpression || res.hasCallExpression;
72
87
  return res.node;
73
88
  }, context);
@@ -87,12 +102,11 @@ const transformer = context => {
87
102
  else {
88
103
  node = TS.visitEachChild(node, node => {
89
104
  const res = visitGeneric(node, { ...options, isJsxAttribute: false });
90
- hasSpread = hasSpread || res.hasSpread;
91
105
  hasCallExpression = hasCallExpression || res.hasCallExpression;
92
106
  return res.node;
93
107
  }, context);
94
108
  }
95
- return { hasSpread, hasCallExpression, node };
109
+ return { node, hasCallExpression };
96
110
  };
97
111
  const visitorExpression = (node, options) => {
98
112
  if (TS.isParenthesizedExpression(node)) {
@@ -104,32 +118,23 @@ const transformer = context => {
104
118
  if (TS.isCallExpression(node)) {
105
119
  let identifier = null;
106
120
  if (node.arguments.length === 0 && (identifier = getSingleIdentifier(node)) != null) {
107
- node = identifier;
108
- }
109
- else {
110
- node = TS.factory.createArrowFunction(void 0, void 0, [], void 0, TS.factory.createToken(TS.SyntaxKind.EqualsGreaterThanToken), TS.visitNode(node, node => visitGeneric(node, {}).node, TS.isConciseBody));
121
+ return visitGeneric(identifier, {}).node;
111
122
  }
112
123
  }
113
- else {
114
- const res = visitGeneric(node, {});
115
- node = res.node;
116
- if (TS.isExpression(node) && !TS.isFunctionLike(node) && !TS.isJsxElement(node) && !TS.isJsxOpeningLikeElement(node)) {
117
- if (res.hasCallExpression) {
118
- node = TS.factory.createArrowFunction(void 0, void 0, [], void 0, TS.factory.createToken(TS.SyntaxKind.EqualsGreaterThanToken), TS.visitNode(node, node => visitGeneric(node, {}).node, TS.isConciseBody));
119
- }
120
- else if (options.userComponent) {
121
- hasChecker = true;
122
- node = TS.factory.createCallExpression(checkerName, void 0, [node]);
123
- }
124
+ const res = visitGeneric(node, {});
125
+ node = res.node;
126
+ if (TS.isExpression(node)) {
127
+ if (options.userComponent || (res.hasCallExpression && !TS.isFunctionLike(node) && !TS.isJsxElement(node) && !TS.isJsxOpeningLikeElement(node))) {
128
+ node = TS.factory.createArrowFunction(void 0, void 0, [], void 0, TS.factory.createToken(TS.SyntaxKind.EqualsGreaterThanToken), node);
124
129
  }
125
130
  }
126
131
  return node;
127
132
  };
128
133
  sourceFile = TS.visitNode(sourceFile, node => visitGeneric(node, {}).node, TS.isSourceFile);
129
- if (hasChecker) {
134
+ if (hasSpreadChecker) {
130
135
  sourceFile = TS.factory.updateSourceFile(sourceFile, [
131
136
  ...sourceFile.statements,
132
- createCheckFunction(checkerName)
137
+ createSpreadCheckFunction(spreadCheckerName)
133
138
  ]);
134
139
  }
135
140
  return sourceFile;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JSX = exports.jsx = exports.Fragment = void 0;
3
+ exports.JSX = exports.Fragment = void 0;
4
4
  exports.jsxs = jsxs;
5
+ exports.jsx = jsx;
5
6
  const NesquickComponent_1 = require("./NesquickComponent");
6
7
  const NesquickFragment_1 = require("./NesquickFragment");
7
- const propsSpreadSymbol = Symbol.for("$nesquickSpreadProps");
8
8
  exports.Fragment = Symbol();
9
9
  function jsxs(type, props, key) {
10
10
  if (type === exports.Fragment) {
@@ -15,7 +15,15 @@ function jsxs(type, props, key) {
15
15
  }
16
16
  return new NesquickComponent_1.NesquickComponent(type, props);
17
17
  }
18
- exports.jsx = jsxs;
18
+ function jsx(type, props, key) {
19
+ if (type === exports.Fragment) {
20
+ return new NesquickFragment_1.NesquickFragment([props.children]);
21
+ }
22
+ if (key !== undefined) {
23
+ props.key = key;
24
+ }
25
+ return new NesquickComponent_1.NesquickComponent(type, props);
26
+ }
19
27
  var JSX;
20
28
  (function (JSX) {
21
29
  })(JSX || (exports.JSX = JSX = {}));
@@ -1,18 +1,18 @@
1
- import { Props, JSX } from "../Nesquick";
1
+ import { JSX } from "../Nesquick";
2
2
  import { NesquickFragment } from "../NesquickFragment";
3
3
  type ChildRender<T> = (item: T, i: () => number) => JSX.Element;
4
4
  export type ForProps<T> = {
5
5
  each: T[];
6
- children: ChildRender<T>;
6
+ children: ChildRender<NoInfer<T>>;
7
7
  } & ({
8
8
  ids?: never;
9
- id: (item: T, i: number) => unknown;
9
+ id: (item: NoInfer<T>, i: number) => unknown;
10
10
  } | {
11
- ids: (item: T, i: number) => unknown[];
11
+ ids: (item: NoInfer<T>, i: number) => unknown[];
12
12
  id?: never;
13
13
  } | {
14
14
  ids?: never;
15
15
  id?: never;
16
16
  });
17
- export declare function For<T>(props: Props<ForProps<T>>): NesquickFragment;
17
+ export declare function For<T>(props: ForProps<T>): NesquickFragment;
18
18
  export {};
@@ -1,4 +1,3 @@
1
- import { Props } from "../Nesquick";
2
1
  import { ForProps } from "./For";
3
2
  export type IdMap<T, ID, CHILD> = {
4
3
  getId(item: T, i: number): ID;
@@ -8,11 +7,11 @@ export type IdMap<T, ID, CHILD> = {
8
7
  deleteChild(id: ID): void;
9
8
  clearChilds(): void;
10
9
  };
11
- type IdMapProps<T> = Props<Pick<Extract<ForProps<T>, {
10
+ type IdMapProps<T> = Pick<Extract<ForProps<T>, {
12
11
  id?: unknown;
13
12
  }>, "id"> | Pick<Extract<ForProps<T>, {
14
13
  ids?: unknown;
15
- }>, "ids">>;
14
+ }>, "ids">;
16
15
  export declare function getMap<T, CHILD>(props: Required<Extract<IdMapProps<T>, {
17
16
  id?: unknown;
18
17
  }>>): IdMap<T, unknown, CHILD>;
@@ -1,11 +1,11 @@
1
1
  import { JSX } from "./Nesquick";
2
- import { Child, Children, NesquickComponent, NesquickParent, VeactDocument } from "./NesquickComponent";
2
+ import { Child, NesquickComponent, NesquickParent, VeactDocument } from "./NesquickComponent";
3
3
  export declare class NesquickFragment extends NesquickComponent<{
4
4
  children: Child[];
5
5
  }> implements NesquickParent {
6
6
  private _lastNode;
7
7
  private _fragment;
8
- constructor(children: Children);
8
+ constructor(children: Child[]);
9
9
  render(document: VeactDocument): Node;
10
10
  getDocument(): Document | null;
11
11
  getParent(): Node | null;
@@ -1,3 +1,2 @@
1
1
  import * as TS from "typescript";
2
- export declare function createCheckFunction(fName: TS.Identifier): TS.FunctionDeclaration;
3
2
  export declare const transformer: TS.TransformerFactory<TS.SourceFile>;
@@ -1,33 +1,9 @@
1
1
  import { FunctionComponent, ComponentProps, NesquickComponent } from "./NesquickComponent";
2
2
  import { NesquickFragment } from "./NesquickFragment";
3
- declare const propsSpreadSymbol: unique symbol;
4
3
  export declare const Fragment: unique symbol;
5
- export declare function jsxs<P extends ComponentProps & {
6
- [propsSpreadSymbol]?: true;
7
- }>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key?: string | number | null): NesquickFragment | NesquickComponent<P>;
8
- export declare const jsx: typeof jsxs;
9
- type HasUndefined<T, K extends keyof T> = {
10
- [L in K]-?: T[K] | undefined;
11
- } extends {
12
- [L in K]?: T[K];
13
- } ? undefined extends T[K] ? true : false : false;
14
- declare const WrappedFunctionType: unique symbol;
15
- type WrappedFunction<T> = (() => T) & {
16
- readonly [WrappedFunctionType]?: T;
17
- };
18
- type UserProp<T> = T extends (...args: any[]) => any ? T : WrappedFunction<T>;
19
- type UserProps<T> = {
20
- readonly [K in keyof T]: K extends keyof JSX.ElementChildrenAttribute ? T[K] : HasUndefined<T, K> extends true ? UserProp<T[K] | undefined> : UserProp<Exclude<T[K], undefined>>;
21
- };
22
- type JSXProp<T> = T extends {
23
- readonly [WrappedFunctionType]?: infer R;
24
- } ? R : T;
25
- type JSXProps<T> = keyof T extends never ? {} : {
26
- [K in keyof T]: JSXProp<T[K]>;
27
- };
28
- export type Generic<T> = T extends (...args: any) => infer R ? R : T;
29
- export { UserProps as Props };
30
- export type Component<P = {}> = (props: UserProps<P>) => JSX.Element;
4
+ export declare function jsxs<P extends ComponentProps>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key?: string | number | null): NesquickFragment | NesquickComponent<P>;
5
+ export declare function jsx<P extends ComponentProps>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key?: string | number | null): NesquickFragment | NesquickComponent<P>;
6
+ export type Component<P extends Record<any, any> = {}> = (props: P) => JSX.Element;
31
7
  export declare namespace JSX {
32
8
  export type JSXEvent<T extends Event, T2 extends EventTarget> = T & {
33
9
  currentTarget: T2;
@@ -67,6 +43,5 @@ export declare namespace JSX {
67
43
  export interface ElementChildrenAttribute {
68
44
  children: {};
69
45
  }
70
- export type LibraryManagedAttributes<_, P> = JSXProps<P>;
71
46
  export {};
72
47
  }
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "nesquick",
3
- "version": "1.4.0",
3
+ "version": "2.0.0",
4
4
  "description": "React-like library with focus on drawing performance",
5
5
  "types": "./lib/types/index.d.ts",
6
6
  "main": "./lib/index.js",
7
7
  "typesVersions": {
8
8
  "*": {
9
- ".": ["./lib/types/index.d.ts"],
10
- "jsx-runtime": ["./lib/types/jsx-runtime.d.ts"],
11
- "jsx-dev-runtime": ["./lib/types/jsx-dev-runtime.d.ts"],
12
- "no-transformer/jsx-runtime": ["./lib/types/jsx-runtime.d.ts"],
13
- "no-transformer/jsx-dev-runtime": ["./lib/types/jsx-dev-runtime.d.ts"]
9
+ ".": [
10
+ "./lib/types/index.d.ts"
11
+ ],
12
+ "jsx-runtime": [
13
+ "./lib/types/jsx-runtime.d.ts"
14
+ ],
15
+ "jsx-dev-runtime": [
16
+ "./lib/types/jsx-dev-runtime.d.ts"
17
+ ]
14
18
  }
15
19
  },
16
20
  "exports": {
@@ -25,14 +29,6 @@
25
29
  "./jsx-dev-runtime": {
26
30
  "types": "./lib/types/jsx-dev-runtime.d.ts",
27
31
  "default": "./lib/jsx-dev-runtime.js"
28
- },
29
- "./no-transformer/jsx-runtime": {
30
- "types": "./lib/types/no-transformer/jsx-runtime.d.ts",
31
- "default": "./lib/no-transformer/jsx-runtime.js"
32
- },
33
- "./no-transformer/jsx-dev-runtime": {
34
- "types": "./lib/types/no-transformer/jsx-dev-runtime.d.ts",
35
- "default": "./lib/no-transformer/jsx-dev-runtime.js"
36
32
  }
37
33
  },
38
34
  "bin": {
@@ -42,7 +38,6 @@
42
38
  "sideEffects": false,
43
39
  "files": [
44
40
  "lib/",
45
- "no-transformer/",
46
41
  "jsx-runtime.js",
47
42
  "jsx-dev-runtime.js"
48
43
  ],
@@ -70,7 +65,7 @@
70
65
  "devDependencies": {
71
66
  "@types/jsdom": "^21.1.7",
72
67
  "@types/node": "^22.7.8",
73
- "arrange-act-assert": "^2.9.3",
68
+ "arrange-act-assert": "^2.10.0",
74
69
  "jsdom": "^26.1.0",
75
70
  "typescript": "^5.6.3"
76
71
  }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.jsxDEV = jsxDEV;
18
- const jsx_runtime_1 = require("./jsx-runtime");
19
- __exportStar(require("./jsx-runtime"), exports);
20
- function jsxDEV(type, props, key, _isStaticChildren, _source, _self) {
21
- return (0, jsx_runtime_1.jsx)(type, props, key);
22
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.JSX = exports.jsx = exports.Fragment = void 0;
4
- exports.functionizeProps = functionizeProps;
5
- exports.jsxs = jsxs;
6
- const NesquickComponent_1 = require("../NesquickComponent");
7
- const NesquickFragment_1 = require("../NesquickFragment");
8
- exports.Fragment = Symbol();
9
- function functionizeProps(props) {
10
- for (const k in props) {
11
- if (k !== "children" && typeof props[k] !== "function") {
12
- const v = props[k];
13
- props[k] = () => v;
14
- }
15
- }
16
- }
17
- function jsxs(type, props, key) {
18
- if (type === exports.Fragment) {
19
- return new NesquickFragment_1.NesquickFragment(props.children);
20
- }
21
- if (typeof type !== "string") {
22
- functionizeProps(props);
23
- }
24
- else if (key !== undefined) {
25
- props.key = key;
26
- }
27
- return new NesquickComponent_1.NesquickComponent(type, props);
28
- }
29
- exports.jsx = jsxs;
30
- var JSX;
31
- (function (JSX) {
32
- })(JSX || (exports.JSX = JSX = {}));
@@ -1,9 +0,0 @@
1
- import { Fragment } from "./jsx-runtime";
2
- import { FunctionComponent, ComponentProps } from "../NesquickComponent";
3
- export * from "./jsx-runtime";
4
- type JsxSource = {
5
- fileName: string;
6
- lineNumber: number;
7
- columnNumber?: number;
8
- };
9
- export declare function jsxDEV<P extends ComponentProps>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key: string | number | null, _isStaticChildren: boolean, _source: JsxSource, _self: any): import("..").NesquickFragment | import("../NesquickComponent").NesquickComponent<P>;
@@ -1,72 +0,0 @@
1
- import { FunctionComponent, ComponentProps, NesquickComponent } from "../NesquickComponent";
2
- import { NesquickFragment } from "../NesquickFragment";
3
- export declare const Fragment: unique symbol;
4
- export declare function functionizeProps(props: ComponentProps): void;
5
- export declare function jsxs<P extends ComponentProps>(type: string | FunctionComponent<P> | typeof Fragment, props: P, key?: string | number | null): NesquickFragment | NesquickComponent<P>;
6
- export declare const jsx: typeof jsxs;
7
- type HasUndefined<T, K extends keyof T> = {
8
- [L in K]-?: T[K] | undefined;
9
- } extends {
10
- [L in K]?: T[K];
11
- } ? undefined extends T[K] ? true : false : false;
12
- declare const WrappedFunctionType: unique symbol;
13
- type WrappedFunction<T> = (() => T) & {
14
- readonly [WrappedFunctionType]?: T;
15
- };
16
- type UserProp<T> = T extends (...args: infer A) => infer R ? (((...args: A) => R) | T) : WrappedFunction<T>;
17
- type UserProps<T> = {
18
- readonly [K in keyof T]: K extends keyof JSX.ElementChildrenAttribute ? T[K] : HasUndefined<T, K> extends true ? UserProp<T[K] | undefined> : UserProp<Exclude<T[K], undefined>>;
19
- };
20
- type JSXProp<T> = T extends {
21
- readonly [WrappedFunctionType]?: infer R;
22
- } ? (T | R) : T extends (...args: any[]) => any ? T : (T | (() => T));
23
- type JSXProps<T> = keyof T extends never ? {} : {
24
- [K in keyof T]: JSXProp<T[K]>;
25
- };
26
- export type Generic<T> = T extends (...args: any) => infer R ? R : T;
27
- export { UserProps as Props };
28
- export type Component<P = {}> = (props: UserProps<P>) => JSX.Element;
29
- export declare namespace JSX {
30
- export type JSXEvent<T extends Event, T2 extends EventTarget> = T & {
31
- currentTarget: T2;
32
- };
33
- export type JSXHTMLEvent<T extends EventTarget> = {
34
- [K in keyof HTMLElementEventMap as `on${Capitalize<K>}`]?: (e: JSXEvent<HTMLElementEventMap[K], T>) => void;
35
- };
36
- export type JSXSVGEvent<T extends EventTarget> = {
37
- [K in keyof SVGElementEventMap as `on${Capitalize<K>}`]?: (e: JSXEvent<SVGElementEventMap[K], T>) => void;
38
- };
39
- export interface Props<T extends EventTarget = HTMLElement> extends JSXHTMLEvent<T>, JSXSVGEvent<T> {
40
- [k: string]: any;
41
- style?: Style;
42
- xmlns?: string | null;
43
- ref?: ((el: T) => void) | null;
44
- }
45
- export type Style = StyleProps | string;
46
- export type StyleProps = {
47
- [K in keyof CSSStyleDeclaration]?: CSSStyleDeclaration[K] extends Function ? never : CSSStyleDeclaration[K] | (() => CSSStyleDeclaration[K]);
48
- };
49
- export type HTMLProps<T extends HTMLElement = HTMLElement> = Props<T>;
50
- export type SVGProps<T extends SVGElement = SVGElement> = Props<T>;
51
- export type JSXElements = {
52
- [K in keyof HTMLElementTagNameMap]: HTMLProps<HTMLElementTagNameMap[K]>;
53
- } & {
54
- [K in keyof SVGElementTagNameMap]: SVGProps<SVGElementTagNameMap[K]>;
55
- };
56
- export type Element = NesquickComponent<any>;
57
- export interface IntrinsicElements extends JSXElements {
58
- }
59
- export type ElementType = keyof IntrinsicElements | Component<any> | typeof NesquickComponent<any>;
60
- const NotEmptyObject: unique symbol;
61
- export type IntrinsicAttributes = {
62
- [NotEmptyObject]?: typeof NotEmptyObject;
63
- };
64
- export interface ElementAttributesProperty {
65
- props: {};
66
- }
67
- export interface ElementChildrenAttribute {
68
- children: {};
69
- }
70
- export type LibraryManagedAttributes<_, P> = JSXProps<P>;
71
- export {};
72
- }