jsx-object 1.0.0 → 1.0.1
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/dist/index.d.cts +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/jsx-runtime.cjs +8 -8
- package/dist/jsx-runtime.d.cts.map +1 -1
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +8 -8
- package/dist/jsx-runtime.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -7,7 +7,7 @@ declare global {
|
|
|
7
7
|
* A `JSX.Element` is always the component object, unless one of their children is a Promise,
|
|
8
8
|
* which makes it also be a Promise
|
|
9
9
|
*/
|
|
10
|
-
type Element
|
|
10
|
+
type Element = ComponentObject | Promise<ComponentObject>;
|
|
11
11
|
interface IntrinsicAttributes {
|
|
12
12
|
/**
|
|
13
13
|
* In `react-jsx`, the `'key'` attribute serves as a reserved attribute name.
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["_$__index_js0.Children"],"sources":["../src/jsx.ts","../src/index.ts"],"mappings":"A,QAAQ;YACI;cACE;OACP;;;;;;SAOE,
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["_$__index_js0.Children"],"sources":["../src/jsx.ts","../src/index.ts"],"mappings":"A,QAAQ;YACI;cACE;OACP;;;;;;SAOE,UAAU,kBAAkB,QAAQ;cAE/B;;;;;;;;;;;MAWR;;cAGQ;MACR,uBAjB+BA;;;;;;;;cA0BvB;;;YClCF,8BAGR,IAAI,UACJ,QAAQ,YACR;YAEQ,kBAAkB;EAAY,WAAW;IAAa;YAEtD,UAAU,WAAW,YAAY,OAAO,kBAAkB,OAAO,IAAI;wBAEjE,SACd,OAAO,oBACN,IAAI"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare global {
|
|
|
7
7
|
* A `JSX.Element` is always the component object, unless one of their children is a Promise,
|
|
8
8
|
* which makes it also be a Promise
|
|
9
9
|
*/
|
|
10
|
-
type Element
|
|
10
|
+
type Element = ComponentObject | Promise<ComponentObject>;
|
|
11
11
|
interface IntrinsicAttributes {
|
|
12
12
|
/**
|
|
13
13
|
* In `react-jsx`, the `'key'` attribute serves as a reserved attribute name.
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__index_js0.Children"],"sources":["../src/jsx.ts","../src/index.ts"],"mappings":"A,QAAQ;YACI;cACE;OACP;;;;;;SAOE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__index_js0.Children"],"sources":["../src/jsx.ts","../src/index.ts"],"mappings":"A,QAAQ;YACI;cACE;OACP;;;;;;SAOE,UAAU,kBAAkB,QAAQ;cAE/B;;;;;;;;;;;MAWR;;cAGQ;MACR,uBAjB+BA;;;;;;;;cA0BvB;;;YClCF,8BAGR,IAAI,UACJ,QAAQ,YACR;YAEQ,kBAAkB;EAAY,WAAW;IAAa;YAEtD,UAAU,WAAW,YAAY,OAAO,kBAAkB,OAAO,IAAI;wBAEjE,SACd,OAAO,oBACN,IAAI"}
|
package/dist/jsx-runtime.cjs
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_index = require("./index.cjs");
|
|
3
3
|
// src/jsx-runtime.ts
|
|
4
|
-
const processResult = (name, props
|
|
5
|
-
if (typeof name === "function") return name(
|
|
6
|
-
|
|
7
|
-
children
|
|
8
|
-
});
|
|
9
|
-
return children;
|
|
4
|
+
const processResult = (name, props) => {
|
|
5
|
+
if (typeof name === "function") return name(props);
|
|
6
|
+
return props.children;
|
|
10
7
|
};
|
|
11
8
|
const isPromise = (value) => {
|
|
12
9
|
return value && typeof value === "object" && typeof value.then === "function";
|
|
@@ -27,9 +24,12 @@ const resolveChildren = (children) => {
|
|
|
27
24
|
};
|
|
28
25
|
function jsx(name, attributes) {
|
|
29
26
|
if (hasPromise(attributes.children)) return resolveChildren(attributes.children).then((children) => {
|
|
30
|
-
return processResult(name,
|
|
27
|
+
return processResult(name, {
|
|
28
|
+
...attributes,
|
|
29
|
+
children
|
|
30
|
+
});
|
|
31
31
|
});
|
|
32
|
-
return processResult(name, attributes
|
|
32
|
+
return processResult(name, attributes);
|
|
33
33
|
}
|
|
34
34
|
function jsxs(name, attributes) {
|
|
35
35
|
return jsx(name, attributes);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.cts","names":[],"sources":["../src/jsx-runtime.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.cts","names":[],"sources":["../src/jsx-runtime.ts"],"mappings":";wBAoCgB,IACd,YACA,eAAe,UACf;EAAc,WAAW;GAAW;IACnC,IAAI;wBAUS,KACd,YACA,eAAe,UACf;EAAc,UAAU;GAAa;IACpC,IAAI"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.d.ts","names":[],"sources":["../src/jsx-runtime.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"jsx-runtime.d.ts","names":[],"sources":["../src/jsx-runtime.ts"],"mappings":";wBAoCgB,IACd,YACA,eAAe,UACf;EAAc,WAAW;GAAW;IACnC,IAAI;wBAUS,KACd,YACA,eAAe,UACf;EAAc,UAAU;GAAa;IACpC,IAAI"}
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Fragment } from "./index.js";
|
|
2
2
|
// src/jsx-runtime.ts
|
|
3
|
-
const processResult = (name, props
|
|
4
|
-
if (typeof name === "function") return name(
|
|
5
|
-
|
|
6
|
-
children
|
|
7
|
-
});
|
|
8
|
-
return children;
|
|
3
|
+
const processResult = (name, props) => {
|
|
4
|
+
if (typeof name === "function") return name(props);
|
|
5
|
+
return props.children;
|
|
9
6
|
};
|
|
10
7
|
const isPromise = (value) => {
|
|
11
8
|
return value && typeof value === "object" && typeof value.then === "function";
|
|
@@ -26,9 +23,12 @@ const resolveChildren = (children) => {
|
|
|
26
23
|
};
|
|
27
24
|
function jsx(name, attributes) {
|
|
28
25
|
if (hasPromise(attributes.children)) return resolveChildren(attributes.children).then((children) => {
|
|
29
|
-
return processResult(name,
|
|
26
|
+
return processResult(name, {
|
|
27
|
+
...attributes,
|
|
28
|
+
children
|
|
29
|
+
});
|
|
30
30
|
});
|
|
31
|
-
return processResult(name, attributes
|
|
31
|
+
return processResult(name, attributes);
|
|
32
32
|
}
|
|
33
33
|
function jsxs(name, attributes) {
|
|
34
34
|
return jsx(name, attributes);
|
package/dist/jsx-runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import type { Children } from './index.js';\n\nconst processResult = (name: string | Function
|
|
1
|
+
{"version":3,"file":"jsx-runtime.js","names":[],"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import type { Children } from './index.js';\n\nconst processResult = (\n name: string | Function,\n props: { children?: Children; [k: string]: any },\n) => {\n if (typeof name === 'function') {\n return name(props);\n }\n\n return props.children;\n}\n\nconst isPromise = (value: any): value is Promise<any> => {\n return value && typeof value === 'object' && typeof value.then === 'function';\n}\n\n/**\n * Checks whether the children are a promise or contain one, at any array depth.\n * Mapped children (e.g. `{items.map(...)}`) are nested arrays inside the children array.\n */\nconst hasPromise = (children: any): boolean => {\n return isPromise(children) || (Array.isArray(children) && children.some(hasPromise));\n}\n\n/**\n * Resolves every promise in the children, keeping nested arrays in place.\n */\nconst resolveChildren = (children: any): Promise<any> => {\n if (Array.isArray(children)) {\n return Promise.all(children.map(resolveChildren));\n }\n\n return Promise.resolve(children);\n}\n\nexport function jsx(\n this: void,\n name: string | Function,\n attributes: { children?: Children; [k: string]: any }\n): JSX.Element {\n if (hasPromise(attributes.children)) {\n return resolveChildren(attributes.children).then(children => {\n return processResult(name, { ...attributes, children });\n });\n }\n\n return processResult(name, attributes);\n}\n\nexport function jsxs(\n this: void,\n name: string | Function,\n attributes: { children: Children[]; [k: string]: any }\n): JSX.Element {\n return jsx(name, attributes);\n}\n\nexport { Fragment } from './index.js'\n"],"mappings":";;AAEA,MAAM,iBACJ,MACA,UACG;CACH,IAAI,OAAO,SAAS,YAClB,OAAO,KAAK,KAAK;CAGnB,OAAO,MAAM;AACf;AAEA,MAAM,aAAa,UAAsC;CACvD,OAAO,SAAS,OAAO,UAAU,YAAY,OAAO,MAAM,SAAS;AACrE;;;;;AAMA,MAAM,cAAc,aAA2B;CAC7C,OAAO,UAAU,QAAQ,KAAM,MAAM,QAAQ,QAAQ,KAAK,SAAS,KAAK,UAAU;AACpF;;;;AAKA,MAAM,mBAAmB,aAAgC;CACvD,IAAI,MAAM,QAAQ,QAAQ,GACxB,OAAO,QAAQ,IAAI,SAAS,IAAI,eAAe,CAAC;CAGlD,OAAO,QAAQ,QAAQ,QAAQ;AACjC;AAEA,SAAgB,IAEd,MACA,YACa;CACb,IAAI,WAAW,WAAW,QAAQ,GAChC,OAAO,gBAAgB,WAAW,QAAQ,CAAC,CAAC,MAAK,aAAY;EAC3D,OAAO,cAAc,MAAM;GAAE,GAAG;GAAY;EAAS,CAAC;CACxD,CAAC;CAGH,OAAO,cAAc,MAAM,UAAU;AACvC;AAEA,SAAgB,KAEd,MACA,YACa;CACb,OAAO,IAAI,MAAM,UAAU;AAC7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsx-object",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Tiny, dependency-free JSX runtime that turns JSX into plain JavaScript objects, with async components. Great for server-driven UI and JSON templating.",
|