princejs 1.8.4 → 1.8.5

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/Readme.md CHANGED
@@ -12,7 +12,7 @@
12
12
  ---
13
13
 
14
14
  ## 🚀 Quick Start
15
-
15
+ s
16
16
  ```bash
17
17
  bun create princejs my-app
18
18
  cd my-app
@@ -122,26 +122,25 @@ app.use(jwt(key));
122
122
  app.use(session({ secret: "key" }));
123
123
  app.use(compress());
124
124
 
125
- const Page = () => (
126
- Html({
127
- children: [
128
- Head({
129
- children: [
130
- "Test Page"
131
- ]
132
- }),
133
- Body({
134
- children: [
135
- H1({
136
- children: "Hello World"
137
- }),
138
- P({
139
- children: "This is a test"
140
- })
141
- ]
142
- })
143
- ]
144
- })
125
+ const Page = () => Html(
126
+ Head("Test Page"),
127
+ Body(
128
+ H1("Hello World"),
129
+ P("This is a test")
130
+ )
131
+ );
132
+
133
+ // With props (optional)
134
+ const Card = (props: any) => Div(
135
+ { className: "card", style: "padding: 1rem;" },
136
+ H1(props.title),
137
+ P(props.content)
138
+ );
139
+
140
+ // Without props
141
+ const Simple = () => Div(
142
+ H1("No Props Needed"),
143
+ P("Just pure content")
145
144
  );
146
145
 
147
146
  const requireAuth = async (req: any, next: any) => {
package/dist/jsx.d.ts CHANGED
@@ -6,11 +6,11 @@ export declare const jsx: (tag: string | Function, props: JSXProps, ...children:
6
6
  export declare const jsxs: (tag: string | Function, props: JSXProps, ...children: any[]) => any;
7
7
  export declare const jsxDEV: (tag: string | Function, props: JSXProps, ...children: any[]) => any;
8
8
  export declare const Fragment: (props: JSXProps) => any;
9
- export declare const Html: (props: any) => string;
10
- export declare const Head: (props: any) => string;
11
- export declare const Body: (props: any) => string;
12
- export declare const H1: (props: any) => string;
13
- export declare const P: (props: any) => string;
14
- export declare const Div: (props: any) => string;
9
+ export declare const Html: (...children: any[]) => string;
10
+ export declare const Head: (...children: any[]) => string;
11
+ export declare const Body: (...children: any[]) => string;
12
+ export declare const H1: (...children: any[]) => string;
13
+ export declare const P: (...children: any[]) => string;
14
+ export declare const Div: (...args: any[]) => string;
15
15
  export declare const render: (jsxContent: any) => Response;
16
16
  //# sourceMappingURL=jsx.d.ts.map
package/dist/jsx.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,GAAG,QAAQ,EAAE,OAAO,QAAQ,EAAE,GAAG,UAAU,GAAG,EAAE,KAAG,GAcjF,CAAC;AAEF,eAAO,MAAM,IAAI,QAhBQ,MAAM,GAAG,QAAQ,SAAS,QAAQ,eAAe,GAAG,EAAE,KAAG,GAgB3D,CAAC;AACxB,eAAO,MAAM,MAAM,QAjBM,MAAM,GAAG,QAAQ,SAAS,QAAQ,eAAe,GAAG,EAAE,KAAG,GAiBzD,CAAC;AAC1B,eAAO,MAAM,QAAQ,GAAI,OAAO,QAAQ,QAAmB,CAAC;AAI5D,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,WAE9B,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,WAE9B,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,OAAO,GAAG,WAE9B,CAAC;AAEF,eAAO,MAAM,EAAE,GAAI,OAAO,GAAG,WAE5B,CAAC;AAEF,eAAO,MAAM,CAAC,GAAI,OAAO,GAAG,WAE3B,CAAC;AAEF,eAAO,MAAM,GAAG,GAAI,OAAO,GAAG,WAU7B,CAAC;AAIF,eAAO,MAAM,MAAM,GAAI,YAAY,GAAG,aAKrC,CAAC"}
1
+ {"version":3,"file":"jsx.d.ts","sourceRoot":"","sources":["../src/jsx.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,eAAO,MAAM,GAAG,GAAI,KAAK,MAAM,GAAG,QAAQ,EAAE,OAAO,QAAQ,EAAE,GAAG,UAAU,GAAG,EAAE,KAAG,GAcjF,CAAC;AAEF,eAAO,MAAM,IAAI,QAhBQ,MAAM,GAAG,QAAQ,SAAS,QAAQ,eAAe,GAAG,EAAE,KAAG,GAgB3D,CAAC;AACxB,eAAO,MAAM,MAAM,QAjBM,MAAM,GAAG,QAAQ,SAAS,QAAQ,eAAe,GAAG,EAAE,KAAG,GAiBzD,CAAC;AAC1B,eAAO,MAAM,QAAQ,GAAI,OAAO,QAAQ,QAAmB,CAAC;AAG5D,eAAO,MAAM,IAAI,GAAI,GAAG,UAAU,GAAG,EAAE,WAEtC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,UAAU,GAAG,EAAE,WAEtC,CAAC;AAEF,eAAO,MAAM,IAAI,GAAI,GAAG,UAAU,GAAG,EAAE,WAEtC,CAAC;AAEF,eAAO,MAAM,EAAE,GAAI,GAAG,UAAU,GAAG,EAAE,WAEpC,CAAC;AAEF,eAAO,MAAM,CAAC,GAAI,GAAG,UAAU,GAAG,EAAE,WAEnC,CAAC;AAEF,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,GAAG,EAAE,WAoBjC,CAAC;AAaF,eAAO,MAAM,MAAM,GAAI,YAAY,GAAG,aAKrC,CAAC"}
package/dist/jsx.js CHANGED
@@ -11,28 +11,37 @@ var jsx = (tag, props, ...children) => {
11
11
  var jsxs = jsx;
12
12
  var jsxDEV = jsx;
13
13
  var Fragment = (props) => props.children;
14
- var Html = (props) => {
15
- return `<html>${renderChildren(props.children)}</html>`;
14
+ var Html = (...children) => {
15
+ return `<html>${renderChildren(children)}</html>`;
16
16
  };
17
- var Head = (props) => {
18
- return `<head>${renderChildren(props.children)}</head>`;
17
+ var Head = (...children) => {
18
+ return `<head>${renderChildren(children)}</head>`;
19
19
  };
20
- var Body = (props) => {
21
- return `<body>${renderChildren(props.children)}</body>`;
20
+ var Body = (...children) => {
21
+ return `<body>${renderChildren(children)}</body>`;
22
22
  };
23
- var H1 = (props) => {
24
- return `<h1>${renderChildren(props.children)}</h1>`;
23
+ var H1 = (...children) => {
24
+ return `<h1>${renderChildren(children)}</h1>`;
25
25
  };
26
- var P = (props) => {
27
- return `<p>${renderChildren(props.children)}</p>`;
26
+ var P = (...children) => {
27
+ return `<p>${renderChildren(children)}</p>`;
28
28
  };
29
- var Div = (props) => {
30
- const attrs = Object.keys(props).filter((key) => key !== "children").map((key) => {
29
+ var Div = (...args) => {
30
+ let options = null;
31
+ let children = args;
32
+ if (args.length > 0 && isPlainObject(args[0])) {
33
+ options = args[0];
34
+ children = args.slice(1);
35
+ }
36
+ const attrs = options ? Object.keys(options).map((key) => {
31
37
  if (key === "className")
32
- return `class="${props[key]}"`;
33
- return `${key}="${props[key]}"`;
34
- }).join(" ");
35
- return `<div ${attrs}>${renderChildren(props.children)}</div>`;
38
+ return `class="${options[key]}"`;
39
+ return `${key}="${options[key]}"`;
40
+ }).join(" ") : "";
41
+ return `<div${attrs ? " " + attrs : ""}>${renderChildren(children)}</div>`;
42
+ };
43
+ var isPlainObject = (obj) => {
44
+ return obj !== null && typeof obj === "object" && !Array.isArray(obj) && !(obj instanceof Date) && !(obj instanceof RegExp) && typeof obj !== "string";
36
45
  };
37
46
  var render = (jsxContent) => {
38
47
  const html = typeof jsxContent === "string" ? jsxContent : String(jsxContent);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "princejs",
3
- "version": "1.8.4",
3
+ "version": "1.8.5",
4
4
  "description": "An easy and fast backend framework that is among the top three — by a 13yo developer, for developers.",
5
5
  "main": "dist/prince.js",
6
6
  "types": "dist/prince.d.ts",