vite-plugin-html-pages 1.4.2 → 1.4.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.
@@ -0,0 +1 @@
1
+ export { Fragment, jsx, jsxDEV, jsxs } from './jsx-runtime.js';
@@ -0,0 +1,44 @@
1
+ // src/jsx-runtime.ts
2
+ import * as tags from "javascript-to-html";
3
+ function flatten(value) {
4
+ if (Array.isArray(value)) {
5
+ return value.flatMap((item) => flatten(item));
6
+ }
7
+ return [value];
8
+ }
9
+ function normalizeChildren(children) {
10
+ return flatten(children).filter((value) => value !== true);
11
+ }
12
+ function renderIntrinsicTag(tagName, props) {
13
+ const tag = tags[tagName];
14
+ if (typeof tag !== "function") {
15
+ throw new Error(
16
+ `[vite-plugin-html-pages] Unknown JSX tag: <${tagName}>`
17
+ );
18
+ }
19
+ const { children, ...rest } = props;
20
+ const normalizedChildren = normalizeChildren(children);
21
+ if (Object.keys(rest).length > 0) {
22
+ return tag(rest, ...normalizedChildren);
23
+ }
24
+ return tag(...normalizedChildren);
25
+ }
26
+ function Fragment(props) {
27
+ return tags.fragment(...normalizeChildren(props.children));
28
+ }
29
+ function jsx(type, props) {
30
+ const finalProps = props ?? {};
31
+ if (typeof type === "function") {
32
+ return type(finalProps);
33
+ }
34
+ return renderIntrinsicTag(type, finalProps);
35
+ }
36
+ var jsxs = jsx;
37
+ var jsxDEV = jsx;
38
+ export {
39
+ Fragment,
40
+ jsx,
41
+ jsxDEV,
42
+ jsxs
43
+ };
44
+ //# sourceMappingURL=jsx-dev-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/jsx-runtime.ts"],"sourcesContent":["import * as tags from 'javascript-to-html';\n\ntype PrimitiveChild = string | number | boolean | null | undefined;\ntype Child = PrimitiveChild | Child[];\n\nfunction flatten(value: Child): PrimitiveChild[] {\n if (Array.isArray(value)) {\n return value.flatMap((item) => flatten(item));\n }\n\n return [value];\n}\n\nfunction normalizeChildren(children: unknown): PrimitiveChild[] {\n return flatten(children as Child).filter((value) => value !== true);\n}\n\ntype Props = Record<string, unknown> & {\n children?: unknown;\n};\n\ntype Component = (props: Props) => unknown;\n\nfunction renderIntrinsicTag(tagName: string, props: Props): string {\n const tag = (tags as Record<string, (...args: unknown[]) => string>)[tagName];\n\n if (typeof tag !== 'function') {\n throw new Error(\n `[vite-plugin-html-pages] Unknown JSX tag: <${tagName}>`,\n );\n }\n\n const { children, ...rest } = props;\n const normalizedChildren = normalizeChildren(children);\n\n if (Object.keys(rest).length > 0) {\n return tag(rest, ...normalizedChildren);\n }\n\n return tag(...normalizedChildren);\n}\n\nexport function Fragment(props: Props): string {\n return tags.fragment(...normalizeChildren(props.children));\n}\n\nexport function jsx(\n type: string | Component,\n props: Props | null,\n): unknown {\n const finalProps = props ?? {};\n\n if (typeof type === 'function') {\n return type(finalProps);\n }\n\n return renderIntrinsicTag(type, finalProps);\n}\n\nexport const jsxs = jsx;\nexport const jsxDEV = jsx;"],"mappings":";AAAA,YAAY,UAAU;AAKtB,SAAS,QAAQ,OAAgC;AAC/C,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,WAAO,MAAM,QAAQ,CAAC,SAAS,QAAQ,IAAI,CAAC;AAAA,EAC9C;AAEA,SAAO,CAAC,KAAK;AACf;AAEA,SAAS,kBAAkB,UAAqC;AAC9D,SAAO,QAAQ,QAAiB,EAAE,OAAO,CAAC,UAAU,UAAU,IAAI;AACpE;AAQA,SAAS,mBAAmB,SAAiB,OAAsB;AACjE,QAAM,MAAO,KAAwD,OAAO;AAE5E,MAAI,OAAO,QAAQ,YAAY;AAC7B,UAAM,IAAI;AAAA,MACR,8CAA8C,OAAO;AAAA,IACvD;AAAA,EACF;AAEA,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAC9B,QAAM,qBAAqB,kBAAkB,QAAQ;AAErD,MAAI,OAAO,KAAK,IAAI,EAAE,SAAS,GAAG;AAChC,WAAO,IAAI,MAAM,GAAG,kBAAkB;AAAA,EACxC;AAEA,SAAO,IAAI,GAAG,kBAAkB;AAClC;AAEO,SAAS,SAAS,OAAsB;AAC7C,SAAY,cAAS,GAAG,kBAAkB,MAAM,QAAQ,CAAC;AAC3D;AAEO,SAAS,IACd,MACA,OACS;AACT,QAAM,aAAa,SAAS,CAAC;AAE7B,MAAI,OAAO,SAAS,YAAY;AAC9B,WAAO,KAAK,UAAU;AAAA,EACxB;AAEA,SAAO,mBAAmB,MAAM,UAAU;AAC5C;AAEO,IAAM,OAAO;AACb,IAAM,SAAS;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-html-pages",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "author": "Paul Browne",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -41,6 +41,10 @@
41
41
  "./jsx-runtime": {
42
42
  "types": "./dist/jsx-runtime.d.ts",
43
43
  "import": "./dist/jsx-runtime.js"
44
+ },
45
+ "./jsx-dev-runtime": {
46
+ "types": "./dist/jsx-dev-runtime.d.ts",
47
+ "import": "./dist/jsx-dev-runtime.js"
44
48
  }
45
49
  },
46
50
  "scripts": {