rask-ui 0.4.2 → 0.4.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.
@@ -1,5 +1,4 @@
1
- export { jsx, jsxs } from "./jsx-runtime";
1
+ export { jsx, jsxs, Fragment } from "./jsx-runtime";
2
2
  export type { JSX } from "./jsx-runtime";
3
- export { Fragment } from "inferno";
4
3
  export { jsx as jsxDEV } from "./jsx-runtime";
5
4
  //# sourceMappingURL=jsx-dev-runtime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAInC,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"jsx-dev-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-dev-runtime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,YAAY,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIzC,OAAO,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,eAAe,CAAC"}
@@ -1,6 +1,5 @@
1
1
  // JSX dev runtime - adds jsxDEV for development mode
2
- export { jsx, jsxs } from "./jsx-runtime";
3
- export { Fragment } from "inferno";
2
+ export { jsx, jsxs, Fragment } from "./jsx-runtime";
4
3
  // In development mode, TypeScript uses jsxDEV instead of jsx
5
4
  // We just alias it to jsx since we don't need the extra dev-mode params
6
5
  export { jsx as jsxDEV } from "./jsx-runtime";
@@ -1,6 +1,6 @@
1
- import { Component } from "inferno";
1
+ import { Component, Fragment } from "inferno";
2
2
  import type { JSXInternal } from "./jsx";
3
- export { Fragment } from "inferno";
3
+ export { Fragment };
4
4
  export declare function jsx(type: string, props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any>, key?: string): any;
5
5
  export declare function jsx<P>(type: ((props: P) => any) | (new () => Component), props: P & {
6
6
  children?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.d.ts","sourceRoot":"","sources":["../src/jsx-runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAwB,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAIzC,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,wBAAgB,GAAG,CACjB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,cAAc,GAC/B,WAAW,CAAC,aAAa,GACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrB,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AACP,wBAAgB,GAAG,CAAC,CAAC,EACnB,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,GAAG,CAAC,UAAU,SAAS,CAAC,EACjD,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,EAC7B,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AAsBP,wBAAgB,IAAI,CAClB,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,WAAW,CAAC,cAAc,GAC/B,WAAW,CAAC,aAAa,GACzB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACrB,GAAG,CAAC,EAAE,MAAM,GACX,GAAG,CAAC;AACP,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,EACvB,KAAK,EAAE,CAAC,GAAG;IAAE,QAAQ,CAAC,EAAE,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,EAAE,WAAW,IAAI,GAAG,EAAE,MAAM,OAAO,CAAC"}
@@ -1,17 +1,147 @@
1
1
  // JSX runtime implementation
2
- import { createComponentVNode } from "inferno";
3
- import { createElement } from "inferno-create-element";
2
+ import { createComponentVNode, createVNode, createFragment, Fragment, } from "inferno";
4
3
  import { createComponent } from "./component";
5
4
  import { ErrorBoundary } from "./error";
6
- export { Fragment } from "inferno";
7
- export function jsx(type, { children, ...props }, key) {
5
+ export { Fragment };
6
+ // Cache for detecting SVG elements
7
+ const svgElements = new Set([
8
+ "svg",
9
+ "path",
10
+ "circle",
11
+ "rect",
12
+ "line",
13
+ "ellipse",
14
+ "polygon",
15
+ "polyline",
16
+ "g",
17
+ "text",
18
+ "tspan",
19
+ "defs",
20
+ "use",
21
+ "clipPath",
22
+ "mask",
23
+ ]);
24
+ export function jsx(type, props, key) {
25
+ // Handle Fragment specially
26
+ if (type === Fragment) {
27
+ const children = props?.children;
28
+ const propsKey = props?.key !== undefined ? props.key : key;
29
+ // Determine ChildFlags for Fragment children
30
+ let childFlags = 1 /* ChildFlags.HasInvalidChildren */;
31
+ if (children !== undefined && children !== null) {
32
+ if (Array.isArray(children)) {
33
+ if (children.length === 0) {
34
+ childFlags = 1 /* ChildFlags.HasInvalidChildren */;
35
+ }
36
+ else {
37
+ // Check if array contains any primitives
38
+ let hasOnlyVNodes = true;
39
+ for (let i = 0; i < children.length; i++) {
40
+ const child = children[i];
41
+ if (child == null ||
42
+ typeof child === "string" ||
43
+ typeof child === "number" ||
44
+ typeof child === "boolean") {
45
+ hasOnlyVNodes = false;
46
+ break;
47
+ }
48
+ }
49
+ childFlags = hasOnlyVNodes
50
+ ? 4 /* ChildFlags.HasNonKeyedChildren */
51
+ : 0 /* ChildFlags.UnknownChildren */;
52
+ }
53
+ }
54
+ else {
55
+ childFlags = 2 /* ChildFlags.HasVNodeChildren */;
56
+ }
57
+ }
58
+ return createFragment(children, childFlags, propsKey);
59
+ }
8
60
  if (typeof type === "string") {
9
- return createElement(type, { ...props, key }, ...(Array.isArray(children) ? children : [children]));
61
+ const children = props.children;
62
+ const propsKey = props.key !== undefined ? props.key : key;
63
+ // Avoid creating new objects - extract only what we need
64
+ let cleanProps = null;
65
+ let className = null;
66
+ let ref = null;
67
+ if (props) {
68
+ // Fast path: check if we have any props besides children/key
69
+ const propKeys = Object.keys(props);
70
+ if (propKeys.length > 0) {
71
+ for (let i = 0; i < propKeys.length; i++) {
72
+ const propKey = propKeys[i];
73
+ if (propKey === "children" || propKey === "key") {
74
+ continue;
75
+ }
76
+ if (propKey === "className" || propKey === "class") {
77
+ className = props[propKey];
78
+ }
79
+ else if (propKey === "ref") {
80
+ ref = props[propKey];
81
+ }
82
+ else {
83
+ if (!cleanProps)
84
+ cleanProps = {};
85
+ cleanProps[propKey] = props[propKey];
86
+ }
87
+ }
88
+ }
89
+ }
90
+ // Determine VNodeFlags based on element type
91
+ const flags = svgElements.has(type)
92
+ ? 32 /* VNodeFlags.SvgElement */
93
+ : 1 /* VNodeFlags.HtmlElement */;
94
+ // Determine ChildFlags for optimization
95
+ let childFlags = 1 /* ChildFlags.HasInvalidChildren */;
96
+ if (children !== undefined && children !== null) {
97
+ if (Array.isArray(children)) {
98
+ if (children.length === 0) {
99
+ childFlags = 1 /* ChildFlags.HasInvalidChildren */;
100
+ }
101
+ else {
102
+ // Check if array contains any primitives that need normalization
103
+ let hasOnlyVNodes = true;
104
+ for (let i = 0; i < children.length; i++) {
105
+ const child = children[i];
106
+ if (child == null ||
107
+ typeof child === "string" ||
108
+ typeof child === "number" ||
109
+ typeof child === "boolean") {
110
+ hasOnlyVNodes = false;
111
+ break;
112
+ }
113
+ }
114
+ // If array contains primitives, use UnknownChildren to let Inferno normalize
115
+ childFlags = hasOnlyVNodes
116
+ ? 4 /* ChildFlags.HasNonKeyedChildren */
117
+ : 0 /* ChildFlags.UnknownChildren */;
118
+ }
119
+ }
120
+ else if (typeof children === "string" || typeof children === "number") {
121
+ childFlags = 16 /* ChildFlags.HasTextChildren */;
122
+ }
123
+ else {
124
+ childFlags = 2 /* ChildFlags.HasVNodeChildren */;
125
+ }
126
+ }
127
+ // Use createVNode directly - much faster than createElement
128
+ return createVNode(flags, type, className, children, childFlags, cleanProps, propsKey, ref);
10
129
  }
11
130
  if (type === ErrorBoundary) {
12
- return createComponentVNode(14 /* VNodeFlags.Component */, ErrorBoundary, { ...props, children }, key);
131
+ return createComponentVNode(14 /* VNodeFlags.Component */, ErrorBoundary, props, key);
132
+ }
133
+ // For custom components, add __component to existing props object
134
+ // Only create new object if we need to add __component
135
+ if (props && props.__component === type) {
136
+ return createComponent(props, key);
137
+ }
138
+ const componentProps = { __component: type };
139
+ if (props) {
140
+ for (const k in props) {
141
+ componentProps[k] = props[k];
142
+ }
13
143
  }
14
- return createComponent({ ...props, children, __component: type }, key);
144
+ return createComponent(componentProps, key);
15
145
  }
16
146
  export function jsxs(type, props, key) {
17
147
  return jsx(type, props, key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rask-ui",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -38,7 +38,6 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "inferno": "^9.0.4",
41
- "inferno-create-element": "^9.0.4",
42
41
  "inferno-vnode-flags": "^9.0.4"
43
42
  }
44
43
  }