jsx-framework-pb 0.0.2 → 0.0.4

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.ts CHANGED
@@ -1 +1,6 @@
1
- export { Fragment, K as Key, P as PropsWithChildren, V as VNode, jsx, jsxs } from './jsx-runtime.js';
1
+ export { K as Key, P as PropsWithChildren, V as VNode } from './types-CfBV6pAD.js';
2
+ export { Fragment, jsx, jsxs } from './jsx-runtime.js';
3
+
4
+ declare function render(vnode: any, container: HTMLElement): void;
5
+
6
+ export { render };
package/dist/index.js CHANGED
@@ -3,9 +3,43 @@ import {
3
3
  jsx,
4
4
  jsxs
5
5
  } from "./chunk-XVAMNTOW.js";
6
+
7
+ // src/render.ts
8
+ function render(vnode, container) {
9
+ container.appendChild(createNode(vnode));
10
+ }
11
+ function createNode(vnode) {
12
+ var _a, _b;
13
+ if (typeof vnode === "string" || typeof vnode === "number") {
14
+ return document.createTextNode(String(vnode));
15
+ }
16
+ if ((vnode == null ? void 0 : vnode.type) === Fragment) {
17
+ const frag = document.createDocumentFragment();
18
+ normalize((_a = vnode.props) == null ? void 0 : _a.children).forEach(
19
+ (c) => frag.appendChild(createNode(c))
20
+ );
21
+ return frag;
22
+ }
23
+ if (typeof (vnode == null ? void 0 : vnode.type) === "function") {
24
+ return createNode(vnode.type(vnode.props));
25
+ }
26
+ const el = document.createElement(vnode.type);
27
+ const { children, ...props } = (_b = vnode.props) != null ? _b : {};
28
+ for (const key in props) {
29
+ el[key] = props[key];
30
+ }
31
+ normalize(children).forEach(
32
+ (c) => el.appendChild(createNode(c))
33
+ );
34
+ return el;
35
+ }
36
+ function normalize(children) {
37
+ return children == null ? [] : Array.isArray(children) ? children : [children];
38
+ }
6
39
  export {
7
40
  Fragment,
8
41
  jsx,
9
- jsxs
42
+ jsxs,
43
+ render
10
44
  };
11
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/render.ts"],"sourcesContent":["import { Fragment } from './jsx-runtime';\r\nimport type { VNode } from './types';\r\n\r\nexport function render(vnode: any, container: HTMLElement) {\r\n container.appendChild(createNode(vnode));\r\n}\r\n\r\nfunction createNode(vnode: any): Node {\r\n if (typeof vnode === \"string\" || typeof vnode === \"number\") {\r\n return document.createTextNode(String(vnode));\r\n }\r\n\r\n if (vnode?.type === Fragment) {\r\n const frag = document.createDocumentFragment();\r\n normalize(vnode.props?.children).forEach(c =>\r\n frag.appendChild(createNode(c))\r\n );\r\n return frag;\r\n }\r\n\r\n if (typeof vnode?.type === \"function\") {\r\n return createNode(vnode.type(vnode.props));\r\n }\r\n\r\n const el = document.createElement(vnode.type);\r\n\r\n const { children, ...props } = vnode.props ?? {};\r\n\r\n for (const key in props) {\r\n el[key] = props[key];\r\n }\r\n\r\n normalize(children).forEach(c =>\r\n el.appendChild(createNode(c))\r\n );\r\n\r\n return el;\r\n}\r\n\r\nfunction normalize(children: any) {\r\n return children == null\r\n ? []\r\n : Array.isArray(children)\r\n ? children\r\n : [children];\r\n}\r\n"],"mappings":";;;;;;;AAGO,SAAS,OAAO,OAAY,WAAwB;AACvD,YAAU,YAAY,WAAW,KAAK,CAAC;AAC3C;AAEA,SAAS,WAAW,OAAkB;AAPtC;AAQI,MAAI,OAAO,UAAU,YAAY,OAAO,UAAU,UAAU;AACxD,WAAO,SAAS,eAAe,OAAO,KAAK,CAAC;AAAA,EAChD;AAEA,OAAI,+BAAO,UAAS,UAAU;AAC1B,UAAM,OAAO,SAAS,uBAAuB;AAC7C,eAAU,WAAM,UAAN,mBAAa,QAAQ,EAAE;AAAA,MAAQ,OACrC,KAAK,YAAY,WAAW,CAAC,CAAC;AAAA,IAClC;AACA,WAAO;AAAA,EACX;AAEA,MAAI,QAAO,+BAAO,UAAS,YAAY;AACnC,WAAO,WAAW,MAAM,KAAK,MAAM,KAAK,CAAC;AAAA,EAC7C;AAEA,QAAM,KAAK,SAAS,cAAc,MAAM,IAAI;AAE5C,QAAM,EAAE,UAAU,GAAG,MAAM,KAAI,WAAM,UAAN,YAAe,CAAC;AAE/C,aAAW,OAAO,OAAO;AACrB,OAAG,GAAG,IAAI,MAAM,GAAG;AAAA,EACvB;AAEA,YAAU,QAAQ,EAAE;AAAA,IAAQ,OACxB,GAAG,YAAY,WAAW,CAAC,CAAC;AAAA,EAChC;AAEA,SAAO;AACX;AAEA,SAAS,UAAU,UAAe;AAC9B,SAAO,YAAY,OACb,CAAC,IACD,MAAM,QAAQ,QAAQ,IAClB,WACA,CAAC,QAAQ;AACvB;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { V as VNode } from './types-CfBV6pAD.js';
2
+
3
+ declare function jsxDEV(type: VNode['type'], props: any, key?: string | number | null, _isStaticChildren?: boolean, _source?: unknown, _self?: unknown): VNode;
4
+ declare const jsxsDEV: typeof jsxDEV;
5
+ declare const Fragment: unique symbol;
6
+
7
+ export { Fragment, jsxDEV, jsxsDEV };
@@ -0,0 +1,16 @@
1
+ import {
2
+ jsx
3
+ } from "./chunk-XVAMNTOW.js";
4
+
5
+ // src/jsx-dev-runtime.ts
6
+ function jsxDEV(type, props, key, _isStaticChildren, _source, _self) {
7
+ return jsx(type, props, key);
8
+ }
9
+ var jsxsDEV = jsxDEV;
10
+ var Fragment = /* @__PURE__ */ Symbol("Fragment");
11
+ export {
12
+ Fragment,
13
+ jsxDEV,
14
+ jsxsDEV
15
+ };
16
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-dev-runtime.ts"],"sourcesContent":["import type { VNode } from './types';\r\nimport { jsx } from './jsx-runtime';\r\n\r\nexport function jsxDEV(\r\n type: VNode['type'],\r\n props: any,\r\n key?: string | number | null,\r\n _isStaticChildren?: boolean,\r\n _source?: unknown,\r\n _self?: unknown\r\n): VNode {\r\n return jsx(type, props, key);\r\n}\r\n\r\nexport const jsxsDEV = jsxDEV;\r\nexport const Fragment = Symbol('Fragment');\r\n"],"mappings":";;;;;AAGO,SAAS,OACZ,MACA,OACA,KACA,mBACA,SACA,OACK;AACL,SAAO,IAAI,MAAM,OAAO,GAAG;AAC/B;AAEO,IAAM,UAAU;AAChB,IAAM,WAAW,uBAAO,UAAU;","names":[]}
@@ -1,21 +1,7 @@
1
- declare namespace JSX {
2
- type Element = VNode;
3
- interface IntrinsicElements {
4
- [elemName: string]: any;
5
- }
6
- }
7
- type Key = string | number | null;
8
- type PropsWithChildren<P = {}> = P & {
9
- children?: JSX.Element | JSX.Element[];
10
- };
11
- interface VNode<P = any> {
12
- type: string | Function;
13
- props: P;
14
- key: Key;
15
- }
1
+ import { V as VNode } from './types-CfBV6pAD.js';
16
2
 
17
3
  declare function jsx(type: VNode["type"], props: any, key?: string | number | null): VNode;
18
4
  declare const jsxs: typeof jsx;
19
5
  declare const Fragment: unique symbol;
20
6
 
21
- export { Fragment, type Key as K, type PropsWithChildren as P, type VNode as V, jsx, jsxs };
7
+ export { Fragment, jsx, jsxs };
@@ -0,0 +1,17 @@
1
+ declare namespace JSX {
2
+ type Element = VNode;
3
+ interface IntrinsicElements {
4
+ [elemName: string]: any;
5
+ }
6
+ }
7
+ type Key = string | number | null;
8
+ type PropsWithChildren<P = {}> = P & {
9
+ children?: JSX.Element | JSX.Element[];
10
+ };
11
+ interface VNode<P = any> {
12
+ type: string | Function;
13
+ props: P;
14
+ key: Key;
15
+ }
16
+
17
+ export type { Key as K, PropsWithChildren as P, VNode as V };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jsx-framework-pb",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
@@ -15,6 +15,10 @@
15
15
  "./jsx-runtime": {
16
16
  "types": "./dist/jsx-runtime.d.ts",
17
17
  "default": "./dist/jsx-runtime.js"
18
+ },
19
+ "./jsx-dev-runtime": {
20
+ "types": "./dist/jsx-dev-runtime.d.ts",
21
+ "default": "./dist/jsx-dev-runtime.js"
18
22
  }
19
23
  },
20
24
  "scripts": {