@blinkk/root 2.5.14-alpha.0 → 2.5.14

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.
@@ -3,7 +3,6 @@ import { ComponentType } from 'preact';
3
3
  import { PluginOption, UserConfig, ViteDevServer } from 'vite';
4
4
  import { Options } from 'html-minifier-terser';
5
5
  import { HTMLBeautifyOptions } from 'js-beautify';
6
- import { J as JsxRenderOptions } from './jsx-C8BaDh-4.js';
7
6
 
8
7
  declare class Hooks {
9
8
  private callbacks;
@@ -169,27 +168,6 @@ interface RootUserConfig {
169
168
  * @see {@link https://vitejs.dev/config/} for more information.
170
169
  */
171
170
  vite?: UserConfig;
172
- /**
173
- * Config for the built-in JSX-to-HTML renderer.
174
- *
175
- * - `mode: 'pretty'` (default) — block-level elements render on their own
176
- * line with no indentation.
177
- * - `mode: 'minimal'` — compact output with no extra whitespace.
178
- *
179
- * Use `blockElements` to specify additional custom element tag names that
180
- * should be treated as block-level in pretty mode.
181
- *
182
- * @example
183
- * ```ts
184
- * export default defineConfig({
185
- * jsxRenderer: {
186
- * mode: 'pretty',
187
- * blockElements: ['my-card', 'my-section'],
188
- * },
189
- * });
190
- * ```
191
- */
192
- jsxRenderer?: JsxRenderOptions;
193
171
  /**
194
172
  * Whether to automatically minify HTML output. This is enabled by default,
195
173
  * in order to disable, pass `minifyHtml: false` to root.config.ts.
@@ -492,16 +470,8 @@ declare class Renderer {
492
470
  * - construct alternates for localized URL paths
493
471
  */
494
472
  getSitemap(): Promise<Sitemap>;
495
- private getJsxRenderOptions;
496
- /**
497
- * Renders JSX via either the `@blinkk/root/jsx` package or
498
- * `preact-render-to-string` depending if the `jsxRenderer` config is set up
499
- * in `root.config.ts`.
500
- */
501
- private renderJsx;
502
473
  private getConfiguredStyleEntries;
503
474
  private renderHtml;
504
- private ensureNewline;
505
475
  render404(options?: {
506
476
  currentPath?: string;
507
477
  }): Promise<{
@@ -755,4 +725,4 @@ interface SitemapItem {
755
725
  }>;
756
726
  }
757
727
 
758
- export { type StaticContentResult as A, type GetStaticContent as B, type ContentSecurityPolicyConfig as C, type RouteModule as D, type HandlerRenderOptions as E, type HandlerRenderFn as F, type GetStaticProps as G, type HandlerContext as H, type Sitemap as I, type SitemapItem as J, Renderer as K, type LocaleGroup as L, type MultipartFile as M, type NextFunction as N, type PostBuildOptions as P, type RootConfig as R, SESSION_COOKIE as S, type XFrameOptionsConfig as X, type Request as a, type Response as b, type SessionMiddlewareOptions as c, type SaveSessionOptions as d, Session as e, type Server as f, type Route as g, type RootUserConfig as h, type RootI18nConfig as i, type RootBuildConfig as j, type RootRedirectConfig as k, type RootHeaderConfig as l, type RootSecurityConfig as m, type RootServerConfig as n, defineConfig as o, type ConfigureServerHook as p, type ConfigureServerOptions as q, type PluginHooks as r, sessionMiddleware as s, type Plugin as t, configureServerPlugins as u, getVitePlugins as v, type RouteParams as w, type GetStaticPaths as x, type RequestMiddleware as y, type Handler as z };
728
+ export { type Sitemap as A, type SitemapItem as B, type ContentSecurityPolicyConfig as C, SESSION_COOKIE as D, type SessionMiddlewareOptions as E, type SaveSessionOptions as F, type GetStaticProps as G, type HandlerContext as H, sessionMiddleware as I, Session as J, Renderer as K, type LocaleGroup as L, type MultipartFile as M, type NextFunction as N, type PostBuildOptions as P, type Route as R, type Server as S, type XFrameOptionsConfig as X, type RootUserConfig as a, type RootConfig as b, type RootI18nConfig as c, type RootBuildConfig as d, type RootRedirectConfig as e, type RootHeaderConfig as f, type RootSecurityConfig as g, type RootServerConfig as h, defineConfig as i, type ConfigureServerHook as j, type ConfigureServerOptions as k, type PluginHooks as l, type Plugin as m, configureServerPlugins as n, getVitePlugins as o, type RouteParams as p, type GetStaticPaths as q, type RequestMiddleware as r, type Request as s, type Response as t, type Handler as u, type StaticContentResult as v, type GetStaticContent as w, type RouteModule as x, type HandlerRenderOptions as y, type HandlerRenderFn as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkk/root",
3
- "version": "2.5.14-alpha.0",
3
+ "version": "2.5.14",
4
4
  "author": "s@blinkk.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -11,6 +11,9 @@
11
11
  "url": "git+https://github.com/blinkk/rootjs.git",
12
12
  "directory": "packages/root"
13
13
  },
14
+ "publishConfig": {
15
+ "provenance": true
16
+ },
14
17
  "files": [
15
18
  "bin/*",
16
19
  "dist/**/*",
@@ -40,18 +43,6 @@
40
43
  "types": "./dist/functions.d.ts",
41
44
  "import": "./dist/functions.js"
42
45
  },
43
- "./jsx": {
44
- "types": "./dist/jsx.d.ts",
45
- "import": "./dist/jsx.js"
46
- },
47
- "./jsx/jsx-runtime": {
48
- "types": "./dist/jsx/jsx-runtime.d.ts",
49
- "import": "./dist/jsx/jsx-runtime.js"
50
- },
51
- "./jsx/jsx-dev-runtime": {
52
- "types": "./dist/jsx/jsx-dev-runtime.d.ts",
53
- "import": "./dist/jsx/jsx-dev-runtime.js"
54
- },
55
46
  "./middleware": {
56
47
  "types": "./dist/middleware.d.ts",
57
48
  "import": "./dist/middleware.js"
@@ -101,12 +92,6 @@
101
92
  },
102
93
  "firebase-admin": {
103
94
  "optional": true
104
- },
105
- "preact": {
106
- "optional": true
107
- },
108
- "preact-render-to-string": {
109
- "optional": true
110
95
  }
111
96
  },
112
97
  "devDependencies": {
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/utils/elements.ts","../src/render/html-minify.ts","../src/render/html-pretty.ts","../src/render/route-trie.ts"],"sourcesContent":["export const ELEMENT_RE = /^[a-z][\\w-]*-[\\w-]*$/;\nexport const HTML_ELEMENTS_REGEX = /<([a-z][\\w-]*-[\\w-]*)/g;\n\n/**\n * Returns true if the tagName is a valid custom element tag.\n */\nexport function isValidTagName(tagName: string) {\n return ELEMENT_RE.test(tagName);\n}\n\n/**\n * Returns a list of custom elements used in a src string (e.g. HTML, jsx, lit).\n * NOTE: the impl uses a simple regex, so tagNames used in comments and attr\n * values may be included.\n */\nexport function parseTagNames(src: string): string[] {\n if (!src) {\n return [];\n }\n const tagNames = new Set<string>();\n const matches = Array.from(String(src).matchAll(HTML_ELEMENTS_REGEX));\n for (const match of matches) {\n const tagName = match[1];\n tagNames.add(tagName);\n }\n return Array.from(tagNames);\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {Options} from 'html-minifier-terser';\n\nconst {minify} = require('html-minifier-terser');\n\nexport type HtmlMinifyOptions = Options;\n\nexport async function htmlMinify(\n html: string,\n options?: HtmlMinifyOptions\n): Promise<string> {\n const minifyOptions = options || {\n collapseWhitespace: true,\n removeComments: true,\n preserveLineBreaks: true,\n };\n try {\n const min = await minify(html, minifyOptions);\n return min.trimStart();\n } catch (e) {\n console.error('failed to minify html:', e);\n return html;\n }\n}\n","import {createRequire} from 'module';\n\nconst require = createRequire(import.meta.url);\nimport type {HTMLBeautifyOptions} from 'js-beautify';\n\nconst beautify = require('js-beautify');\n\nexport type HtmlPrettyOptions = HTMLBeautifyOptions;\n\nexport async function htmlPretty(\n html: string,\n options?: HtmlPrettyOptions\n): Promise<string> {\n const prettyOptions = options || {\n indent_size: 0,\n end_with_newline: true,\n extra_liners: [],\n };\n try {\n const output = beautify.html(html, prettyOptions);\n return output.trimStart();\n } catch (e) {\n console.error('failed to pretty html:', e);\n return html;\n }\n}\n","/**\n * A trie data structure that stores routes. Supports Next-style routing using\n * [param], [...catchall], and [[...optcatchall]] placeholders.\n */\nexport class RouteTrie<T> {\n private children: Record<string, RouteTrie<T>> = {};\n private paramNodes?: {[param: string]: ParamNode<T>};\n private catchAllNodes?: CatchAllNode<T>;\n private optCatchAllNodes?: CatchAllNode<T>;\n private route?: T;\n\n /**\n * Adds a route to the trie.\n */\n add(path: string, route: T) {\n path = this.normalizePath(path);\n\n // If the end was reached, save the value to the node.\n if (path === '') {\n this.route = route;\n return;\n }\n\n const [head, tail] = this.splitPath(path);\n\n if (head.startsWith('[[...') && head.endsWith(']]')) {\n const paramName = head.slice(5, -2);\n this.optCatchAllNodes = new CatchAllNode(paramName, route);\n return;\n }\n if (head.startsWith('[...') && head.endsWith(']')) {\n const paramName = head.slice(4, -1);\n this.catchAllNodes = new CatchAllNode(paramName, route);\n return;\n }\n\n let nextNode: RouteTrie<T>;\n if (head.startsWith('[') && head.endsWith(']')) {\n if (!this.paramNodes) {\n this.paramNodes = {};\n }\n const paramName = head.slice(1, -1);\n if (!this.paramNodes[paramName]) {\n this.paramNodes[paramName] = new ParamNode(paramName);\n }\n nextNode = this.paramNodes[paramName].trie;\n } else {\n nextNode = this.children[head];\n if (!nextNode) {\n nextNode = new RouteTrie();\n this.children[head] = nextNode;\n }\n }\n nextNode.add(tail, route);\n }\n\n /**\n * Returns a route mapped to the given path and any parameter values from the\n * URL.\n */\n get(path: string): [T | undefined, Record<string, string>] {\n const params = {};\n const route = this.getRoute(path, params);\n return [route, params];\n }\n\n /**\n * Returns all routes that match the given path and their parameter values.\n */\n matchAll(path: string): Array<[T, Record<string, string>]> {\n const matches: Array<[T, Record<string, string>]> = [];\n this.collectRoutes(path, {}, matches);\n return matches;\n }\n\n /**\n * Walks the route trie and calls a callback function for each route.\n */\n walk(cb: (urlPath: string, route: T) => Promise<void> | void): Promise<void> {\n const promises: Array<Promise<void>> = [];\n const addPromise = (promise: Promise<void> | void) => {\n if (promise) {\n promises.push(promise);\n }\n };\n if (this.route) {\n addPromise(cb('/', this.route));\n }\n if (this.paramNodes) {\n Object.values(this.paramNodes).forEach((paramChild) => {\n const param = `[${paramChild.name}]`;\n paramChild.trie.walk((childPath: string, route: T) => {\n const paramUrlPath = `/${param}${childPath}`;\n addPromise(cb(paramUrlPath, route));\n });\n });\n }\n if (this.catchAllNodes) {\n const wildcardUrlPath = `/[...${this.catchAllNodes.name}]`;\n addPromise(cb(wildcardUrlPath, this.catchAllNodes.route));\n }\n if (this.optCatchAllNodes) {\n const wildcardUrlPath = `/[[...${this.optCatchAllNodes.name}]]`;\n addPromise(cb(wildcardUrlPath, this.optCatchAllNodes.route));\n }\n for (const subpath of Object.keys(this.children)) {\n const childTrie = this.children[subpath];\n childTrie.walk((childPath: string, childRoute: T) => {\n addPromise(cb(`/${subpath}${childPath}`, childRoute));\n });\n }\n return Promise.all(promises).then(() => {});\n }\n\n /**\n * Removes all routes from the trie.\n */\n clear() {\n this.children = {};\n this.paramNodes = undefined;\n this.catchAllNodes = undefined;\n this.optCatchAllNodes = undefined;\n this.route = undefined;\n }\n\n private getRoute(\n urlPath: string,\n params: Record<string, string>\n ): T | undefined {\n urlPath = this.normalizePath(urlPath);\n if (urlPath === '') {\n if (this.route) {\n return this.route;\n }\n if (this.optCatchAllNodes) {\n if (urlPath) {\n params[this.optCatchAllNodes.name] = urlPath;\n }\n return this.optCatchAllNodes.route;\n }\n return undefined;\n }\n\n const [head, tail] = this.splitPath(urlPath);\n\n const child = this.children[head];\n if (child) {\n const route = child.getRoute(tail, params);\n if (route) {\n return route;\n }\n }\n\n if (this.paramNodes) {\n for (const paramChild of Object.values(this.paramNodes)) {\n const route = paramChild.trie.getRoute(tail, params);\n if (route) {\n params[paramChild.name] = head;\n return route;\n }\n }\n }\n\n if (this.catchAllNodes) {\n params[this.catchAllNodes.name] = urlPath;\n return this.catchAllNodes.route;\n }\n\n if (this.optCatchAllNodes) {\n params[this.optCatchAllNodes.name] = urlPath;\n return this.optCatchAllNodes.route;\n }\n\n return undefined;\n }\n\n private collectRoutes(\n urlPath: string,\n params: Record<string, string>,\n results: Array<[T, Record<string, string>]>\n ) {\n urlPath = this.normalizePath(urlPath);\n if (urlPath === '') {\n if (this.route) {\n results.push([this.route, {...params}]);\n }\n if (this.optCatchAllNodes) {\n const optParams = {...params};\n if (urlPath) {\n optParams[this.optCatchAllNodes.name] = urlPath;\n }\n results.push([this.optCatchAllNodes.route, optParams]);\n }\n return;\n }\n\n const [head, tail] = this.splitPath(urlPath);\n\n const child = this.children[head];\n if (child) {\n child.collectRoutes(tail, {...params}, results);\n }\n\n if (this.paramNodes) {\n for (const paramChild of Object.values(this.paramNodes)) {\n const paramParams = {...params, [paramChild.name]: head};\n paramChild.trie.collectRoutes(tail, paramParams, results);\n }\n }\n\n if (this.catchAllNodes) {\n const caParams = {...params, [this.catchAllNodes.name]: urlPath};\n results.push([this.catchAllNodes.route, caParams]);\n }\n\n if (this.optCatchAllNodes) {\n const ocParams = {...params};\n if (urlPath) {\n ocParams[this.optCatchAllNodes.name] = urlPath;\n }\n results.push([this.optCatchAllNodes.route, ocParams]);\n }\n }\n\n /**\n * Normalizes a path for inclusion into the route trie.\n */\n private normalizePath(path: string) {\n // Remove leading/trailing slashes.\n return path.replace(/^\\/+/g, '').replace(/\\/+$/g, '');\n }\n\n /**\n * Splits the parent directory from its children, e.g.:\n *\n * splitPath(\"foo/bar/baz\") -> [\"foo\", \"bar/baz\"]\n */\n private splitPath(path: string): [string, string] {\n const i = path.indexOf('/');\n if (i === -1) {\n return [path, ''];\n }\n return [path.slice(0, i), path.slice(i + 1)];\n }\n}\n\n/**\n * A node in the RouteTrie for a :param child.\n */\nclass ParamNode<T> {\n readonly name: string;\n readonly trie: RouteTrie<T> = new RouteTrie();\n\n constructor(name: string) {\n this.name = name;\n }\n}\n\n/**\n * A node in the RouteTrie for a *wildcard child.\n */\nclass CatchAllNode<T> {\n readonly name: string;\n readonly route: T;\n\n constructor(name: string, route: T) {\n this.name = name;\n this.route = route;\n }\n}\n"],"mappings":";AAAO,IAAM,aAAa;AACnB,IAAM,sBAAsB;AAK5B,SAAS,eAAe,SAAiB;AAC9C,SAAO,WAAW,KAAK,OAAO;AAChC;AAOO,SAAS,cAAc,KAAuB;AACnD,MAAI,CAAC,KAAK;AACR,WAAO,CAAC;AAAA,EACV;AACA,QAAM,WAAW,oBAAI,IAAY;AACjC,QAAM,UAAU,MAAM,KAAK,OAAO,GAAG,EAAE,SAAS,mBAAmB,CAAC;AACpE,aAAW,SAAS,SAAS;AAC3B,UAAM,UAAU,MAAM,CAAC;AACvB,aAAS,IAAI,OAAO;AAAA,EACtB;AACA,SAAO,MAAM,KAA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AAY,MAAc,OAAU;AAClC,SAAK,OAAO;AACZ,SAAK,QAAQ;AAAA,EACf;AACF;","names":["require","createRequire","require"]}
@@ -1,381 +0,0 @@
1
- import {
2
- Fragment
3
- } from "./chunk-CY5IQ4AQ.js";
4
-
5
- // src/jsx/jsx-render.ts
6
- import { options as preactOptions } from "preact";
7
- var VOID_ELEMENTS = /* @__PURE__ */ new Set([
8
- "area",
9
- "base",
10
- "br",
11
- "col",
12
- "embed",
13
- "hr",
14
- "img",
15
- "input",
16
- "link",
17
- "meta",
18
- "param",
19
- "source",
20
- "track",
21
- "wbr"
22
- ]);
23
- var RAW_CONTENT_ELEMENTS = /* @__PURE__ */ new Set(["pre", "textarea", "script", "style"]);
24
- var DEFAULT_BLOCK_ELEMENTS = /* @__PURE__ */ new Set([
25
- "address",
26
- "article",
27
- "aside",
28
- "blockquote",
29
- "body",
30
- "dd",
31
- "details",
32
- "dialog",
33
- "div",
34
- "dl",
35
- "dt",
36
- "fieldset",
37
- "figcaption",
38
- "figure",
39
- "footer",
40
- "form",
41
- "h1",
42
- "h2",
43
- "h3",
44
- "h4",
45
- "h5",
46
- "h6",
47
- "head",
48
- "header",
49
- "hgroup",
50
- "hr",
51
- "html",
52
- "li",
53
- "link",
54
- "main",
55
- "meta",
56
- "nav",
57
- "noscript",
58
- "ol",
59
- "p",
60
- "pre",
61
- "script",
62
- "search",
63
- "section",
64
- "style",
65
- "summary",
66
- "table",
67
- "tbody",
68
- "td",
69
- "tfoot",
70
- "th",
71
- "thead",
72
- "title",
73
- "tr",
74
- "ul"
75
- ]);
76
- var PROP_TO_ATTR = {
77
- acceptCharset: "accept-charset",
78
- autoCapitalize: "autocapitalize",
79
- autoComplete: "autocomplete",
80
- autoFocus: "autofocus",
81
- autoPlay: "autoplay",
82
- charSet: "charset",
83
- className: "class",
84
- colSpan: "colspan",
85
- contentEditable: "contenteditable",
86
- crossOrigin: "crossorigin",
87
- dateTime: "datetime",
88
- encType: "enctype",
89
- formAction: "formaction",
90
- formEncType: "formenctype",
91
- formMethod: "formmethod",
92
- formNoValidate: "formnovalidate",
93
- formTarget: "formtarget",
94
- frameBorder: "frameborder",
95
- hrefLang: "hreflang",
96
- htmlFor: "for",
97
- httpEquiv: "http-equiv",
98
- inputMode: "inputmode",
99
- itemProp: "itemprop",
100
- itemRef: "itemref",
101
- itemScope: "itemscope",
102
- itemType: "itemtype",
103
- maxLength: "maxlength",
104
- mediaGroup: "mediagroup",
105
- minLength: "minlength",
106
- noModule: "nomodule",
107
- noValidate: "novalidate",
108
- playsInline: "playsinline",
109
- readOnly: "readonly",
110
- referrerPolicy: "referrerpolicy",
111
- rowSpan: "rowspan",
112
- spellCheck: "spellcheck",
113
- srcDoc: "srcdoc",
114
- srcLang: "srclang",
115
- srcSet: "srcset",
116
- tabIndex: "tabindex",
117
- useMap: "usemap"
118
- };
119
- var AMP = "&amp;";
120
- var LT = "&lt;";
121
- var GT = "&gt;";
122
- var QUOT = "&quot;";
123
- function isDef(value) {
124
- return value !== null && value !== void 0;
125
- }
126
- function escapeHtml(str) {
127
- let result = "";
128
- let last = 0;
129
- for (let i = 0; i < str.length; i++) {
130
- const ch = str.charCodeAt(i);
131
- let escaped;
132
- if (ch === 38) escaped = AMP;
133
- else if (ch === 60) escaped = LT;
134
- else if (ch === 62) escaped = GT;
135
- if (escaped) {
136
- result += str.slice(last, i) + escaped;
137
- last = i + 1;
138
- }
139
- }
140
- if (last === 0) return str;
141
- return result + str.slice(last);
142
- }
143
- function escapeAttr(str) {
144
- let result = "";
145
- let last = 0;
146
- for (let i = 0; i < str.length; i++) {
147
- const ch = str.charCodeAt(i);
148
- let escaped;
149
- if (ch === 38) escaped = AMP;
150
- else if (ch === 34) escaped = QUOT;
151
- else if (ch === 60) escaped = LT;
152
- else if (ch === 62) escaped = GT;
153
- if (escaped) {
154
- result += str.slice(last, i) + escaped;
155
- last = i + 1;
156
- }
157
- }
158
- if (last === 0) return str;
159
- return result + str.slice(last);
160
- }
161
- function styleToString(style) {
162
- const parts = [];
163
- for (const key in style) {
164
- const value = style[key];
165
- if (!isDef(value) || value === "") continue;
166
- const cssKey = key.replace(/[A-Z]/g, (m) => "-" + m.toLowerCase());
167
- parts.push(`${cssKey}:${value}`);
168
- }
169
- return parts.join(";");
170
- }
171
- function renderJsxToString(vnode, options) {
172
- const mode = options?.mode ?? "pretty";
173
- const isPretty = mode === "pretty";
174
- const blockSet = new Set(DEFAULT_BLOCK_ELEMENTS);
175
- if (options?.blockElements) {
176
- for (const el of options.blockElements) {
177
- blockSet.add(el);
178
- }
179
- }
180
- const contextStacks = /* @__PURE__ */ new Map();
181
- function pushCtx(contextId, value) {
182
- let stack = contextStacks.get(contextId);
183
- if (!stack) {
184
- stack = [];
185
- contextStacks.set(contextId, stack);
186
- }
187
- stack.push(value);
188
- }
189
- function popCtx(contextId) {
190
- contextStacks.get(contextId)?.pop();
191
- }
192
- function buildGlobalContext() {
193
- const globalCtx = {};
194
- for (const [contextId, stack] of contextStacks) {
195
- if (stack.length > 0) {
196
- globalCtx[contextId] = {
197
- props: { value: stack[stack.length - 1] },
198
- sub: noop
199
- };
200
- }
201
- }
202
- return globalCtx;
203
- }
204
- function render(node, inline) {
205
- if (!isDef(node) || typeof node === "boolean") return "";
206
- if (typeof node === "string") return escapeHtml(node);
207
- if (typeof node === "number" || typeof node === "bigint")
208
- return String(node);
209
- if (Array.isArray(node)) return node.map((n) => render(n, inline)).join("");
210
- if (typeof node !== "object" || !("type" in node)) return "";
211
- const { type, props } = node;
212
- if (type === Fragment) {
213
- return renderChildren(props?.children);
214
- }
215
- if (typeof type === "function") {
216
- return renderComponent(node);
217
- }
218
- if (typeof type === "string") {
219
- return renderElement(type, props, inline);
220
- }
221
- return "";
222
- }
223
- function renderComponent(vnode2) {
224
- const { type, props } = vnode2;
225
- const fn = type;
226
- const fnAny = fn;
227
- if (fnAny._isProvider && fnAny._context) {
228
- const ctx = fnAny._context;
229
- ctx._stack.push(props.value);
230
- const result = renderChildren(props.children);
231
- ctx._stack.pop();
232
- return result;
233
- }
234
- let contextId;
235
- if (typeof fnAny.__c === "string" && fnAny.__c.startsWith("__cC")) {
236
- contextId = fnAny.__c;
237
- } else if (fnAny.__ && typeof fnAny.__ === "object" && fnAny.__.__c) {
238
- contextId = fnAny.__.__c;
239
- }
240
- if (contextId) {
241
- pushCtx(contextId, props.value);
242
- const result = renderChildren(props.children);
243
- popCtx(contextId);
244
- return result;
245
- }
246
- if (fn.contextType) {
247
- const ctx = fn.contextType;
248
- const ctxId = ctx.__c;
249
- const stack = contextStacks.get(ctxId);
250
- const value = stack && stack.length > 0 ? stack[stack.length - 1] : ctx.__;
251
- if (typeof props.children === "function") {
252
- return render(props.children(value));
253
- }
254
- return renderChildren(props.children);
255
- }
256
- const component = {
257
- props,
258
- context: buildGlobalContext(),
259
- state: {},
260
- __v: vnode2,
261
- // _vnode
262
- __d: false,
263
- // _dirty
264
- __h: [],
265
- // _renderCallbacks
266
- __s: {},
267
- // _nextState
268
- __H: null
269
- // _hooks (initialised by hooks addon)
270
- };
271
- vnode2.__c = component;
272
- preactOptions.__b?.(vnode2);
273
- preactOptions.__r?.(vnode2);
274
- try {
275
- if (fn.prototype && fn.prototype.render) {
276
- const instance = new fn(props, component.context);
277
- instance.__n = component.__n;
278
- instance.__H = component.__H;
279
- vnode2.__c = instance;
280
- preactOptions.__r?.(vnode2);
281
- return render(instance.render(instance.props, instance.state));
282
- }
283
- const rendered = fn(props, component.context);
284
- return render(rendered);
285
- } finally {
286
- preactOptions.diffed?.(vnode2);
287
- }
288
- }
289
- function renderElement(tag, props, inline) {
290
- const isBlock = isPretty && !inline && blockSet.has(tag);
291
- const isVoid = VOID_ELEMENTS.has(tag);
292
- const attrs = renderAttrs(tag, props);
293
- let result = "<" + tag + attrs + ">";
294
- if (isVoid) {
295
- if (isBlock) result += "\n";
296
- return result;
297
- }
298
- let inner = "";
299
- if (isDef(props?.dangerouslySetInnerHTML?.__html)) {
300
- inner = props.dangerouslySetInnerHTML.__html;
301
- } else if (isDef(props?.children)) {
302
- inner = renderChildren(props.children);
303
- } else if (tag === "textarea" && props) {
304
- const textVal = props.value ?? props.defaultValue;
305
- if (isDef(textVal)) {
306
- inner = escapeHtml(String(textVal));
307
- }
308
- }
309
- if (isBlock) {
310
- const hasBlockChildren = !RAW_CONTENT_ELEMENTS.has(tag) && inner.includes("\n");
311
- if (hasBlockChildren) {
312
- result += "\n" + inner + "</" + tag + ">\n";
313
- } else {
314
- result += inner + "</" + tag + ">\n";
315
- }
316
- } else {
317
- result += inner + "</" + tag + ">";
318
- }
319
- return result;
320
- }
321
- function renderAttrs(tag, props) {
322
- if (!props) return "";
323
- const parts = [];
324
- for (const key in props) {
325
- if (key === "children" || key === "dangerouslySetInnerHTML" || key === "key" || key === "ref" || key === "__self" || key === "__source") {
326
- continue;
327
- }
328
- if (tag === "textarea" && (key === "value" || key === "defaultValue")) {
329
- continue;
330
- }
331
- if (key.length > 2 && key[0] === "o" && key[1] === "n") continue;
332
- let value = props[key];
333
- if (!isDef(value)) continue;
334
- if (value === false && !key.startsWith("data-")) continue;
335
- const attrName = PROP_TO_ATTR[key] || key;
336
- if (value === true) {
337
- parts.push(" ", attrName);
338
- continue;
339
- }
340
- if (key === "style" && typeof value === "object") {
341
- value = styleToString(value);
342
- if (!value) continue;
343
- }
344
- parts.push(" ", attrName, '="', escapeAttr(String(value)), '"');
345
- }
346
- return parts.join("");
347
- }
348
- function isTextNode(child) {
349
- if (!isDef(child) || typeof child === "boolean") return false;
350
- return typeof child === "string" || typeof child === "number" || typeof child === "bigint";
351
- }
352
- function hasMixedContent(children) {
353
- let hasText = false;
354
- let hasElement = false;
355
- for (const child of children) {
356
- if (isTextNode(child)) {
357
- hasText = true;
358
- } else if (isDef(child) && typeof child === "object" && "type" in child) {
359
- hasElement = true;
360
- }
361
- if (hasText && hasElement) return true;
362
- }
363
- return false;
364
- }
365
- function renderChildren(children) {
366
- if (!isDef(children)) return "";
367
- if (Array.isArray(children)) {
368
- const inline = isPretty && hasMixedContent(children);
369
- return children.map((child) => render(child, inline)).join("");
370
- }
371
- return render(children);
372
- }
373
- return render(vnode);
374
- }
375
- function noop() {
376
- }
377
-
378
- export {
379
- renderJsxToString
380
- };
381
- //# sourceMappingURL=chunk-BUAFCL5F.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/jsx/jsx-render.ts"],"sourcesContent":["import {options as preactOptions} from 'preact';\nimport {VNode, Fragment} from './jsx-runtime.js';\n\n/** HTML void elements (self-closing, no end tag). */\nconst VOID_ELEMENTS = new Set([\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n]);\n\n/** Tags whose text content may contain literal newlines that should not be treated as block-child indicators. */\nconst RAW_CONTENT_ELEMENTS = new Set(['pre', 'textarea', 'script', 'style']);\n\n/** Standard HTML block-level elements. */\nconst DEFAULT_BLOCK_ELEMENTS = new Set([\n 'address',\n 'article',\n 'aside',\n 'blockquote',\n 'body',\n 'dd',\n 'details',\n 'dialog',\n 'div',\n 'dl',\n 'dt',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'head',\n 'header',\n 'hgroup',\n 'hr',\n 'html',\n 'li',\n 'link',\n 'main',\n 'meta',\n 'nav',\n 'noscript',\n 'ol',\n 'p',\n 'pre',\n 'script',\n 'search',\n 'section',\n 'style',\n 'summary',\n 'table',\n 'tbody',\n 'td',\n 'tfoot',\n 'th',\n 'thead',\n 'title',\n 'tr',\n 'ul',\n]);\n\n/** JSX prop name -> HTML attribute name. */\nconst PROP_TO_ATTR: Record<string, string> = {\n acceptCharset: 'accept-charset',\n autoCapitalize: 'autocapitalize',\n autoComplete: 'autocomplete',\n autoFocus: 'autofocus',\n autoPlay: 'autoplay',\n charSet: 'charset',\n className: 'class',\n colSpan: 'colspan',\n contentEditable: 'contenteditable',\n crossOrigin: 'crossorigin',\n dateTime: 'datetime',\n encType: 'enctype',\n formAction: 'formaction',\n formEncType: 'formenctype',\n formMethod: 'formmethod',\n formNoValidate: 'formnovalidate',\n formTarget: 'formtarget',\n frameBorder: 'frameborder',\n hrefLang: 'hreflang',\n htmlFor: 'for',\n httpEquiv: 'http-equiv',\n inputMode: 'inputmode',\n itemProp: 'itemprop',\n itemRef: 'itemref',\n itemScope: 'itemscope',\n itemType: 'itemtype',\n maxLength: 'maxlength',\n mediaGroup: 'mediagroup',\n minLength: 'minlength',\n noModule: 'nomodule',\n noValidate: 'novalidate',\n playsInline: 'playsinline',\n readOnly: 'readonly',\n referrerPolicy: 'referrerpolicy',\n rowSpan: 'rowspan',\n spellCheck: 'spellcheck',\n srcDoc: 'srcdoc',\n srcLang: 'srclang',\n srcSet: 'srcset',\n tabIndex: 'tabindex',\n useMap: 'usemap',\n};\n\nconst AMP = '&amp;';\nconst LT = '&lt;';\nconst GT = '&gt;';\nconst QUOT = '&quot;';\n\n/** Returns `true` when `value` is neither `null` nor `undefined`. */\nfunction isDef<T>(value: T | null | undefined): value is T {\n return value !== null && value !== undefined;\n}\n\nfunction escapeHtml(str: string): string {\n let result = '';\n let last = 0;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n let escaped: string | undefined;\n if (ch === 38) escaped = AMP;\n else if (ch === 60) escaped = LT;\n else if (ch === 62) escaped = GT;\n if (escaped) {\n result += str.slice(last, i) + escaped;\n last = i + 1;\n }\n }\n if (last === 0) return str;\n return result + str.slice(last);\n}\n\nfunction escapeAttr(str: string): string {\n let result = '';\n let last = 0;\n for (let i = 0; i < str.length; i++) {\n const ch = str.charCodeAt(i);\n let escaped: string | undefined;\n if (ch === 38) escaped = AMP;\n else if (ch === 34) escaped = QUOT;\n else if (ch === 60) escaped = LT;\n else if (ch === 62) escaped = GT;\n if (escaped) {\n result += str.slice(last, i) + escaped;\n last = i + 1;\n }\n }\n if (last === 0) return str;\n return result + str.slice(last);\n}\n\nfunction styleToString(style: Record<string, any>): string {\n const parts: string[] = [];\n for (const key in style) {\n const value = style[key];\n if (!isDef(value) || value === '') continue;\n // Convert camelCase to kebab-case.\n const cssKey = key.replace(/[A-Z]/g, (m) => '-' + m.toLowerCase());\n parts.push(`${cssKey}:${value}`);\n }\n return parts.join(';');\n}\n\nexport interface JsxRenderOptions {\n /** Render mode. `'pretty'` adds newlines around block elements; `'minimal'` outputs compact HTML. Default: `'pretty'`. */\n mode?: 'pretty' | 'minimal';\n /** Additional tag names to treat as block-level elements in pretty mode. */\n blockElements?: string[];\n}\n\n/**\n * Renders a Preact VNode tree to an HTML string.\n */\nexport function renderJsxToString(\n vnode: VNode,\n options?: JsxRenderOptions\n): string {\n const mode = options?.mode ?? 'pretty';\n const isPretty = mode === 'pretty';\n const blockSet = new Set(DEFAULT_BLOCK_ELEMENTS);\n if (options?.blockElements) {\n for (const el of options.blockElements) {\n blockSet.add(el);\n }\n }\n\n // Context stacks: context.__c (id) -> value[]\n const contextStacks = new Map<string, any[]>();\n\n function pushCtx(contextId: string, value: any) {\n let stack = contextStacks.get(contextId);\n if (!stack) {\n stack = [];\n contextStacks.set(contextId, stack);\n }\n stack.push(value);\n }\n\n function popCtx(contextId: string) {\n contextStacks.get(contextId)?.pop();\n }\n\n /** Builds the __n (global context) map for hooks. */\n function buildGlobalContext(): Record<string, any> {\n const globalCtx: Record<string, any> = {};\n for (const [contextId, stack] of contextStacks) {\n if (stack.length > 0) {\n // useContext expects provider.props.value and provider.sub().\n globalCtx[contextId] = {\n props: {value: stack[stack.length - 1]},\n sub: noop,\n };\n }\n }\n return globalCtx;\n }\n\n function render(node: any, inline?: boolean): string {\n if (!isDef(node) || typeof node === 'boolean') return '';\n if (typeof node === 'string') return escapeHtml(node);\n if (typeof node === 'number' || typeof node === 'bigint')\n return String(node);\n if (Array.isArray(node)) return node.map((n) => render(n, inline)).join('');\n\n // Must be a VNode-like object.\n if (typeof node !== 'object' || !('type' in node)) return '';\n\n const {type, props} = node;\n\n // Fragment.\n if (type === Fragment) {\n return renderChildren(props?.children);\n }\n\n // Component (function or class).\n if (typeof type === 'function') {\n return renderComponent(node);\n }\n\n // HTML element.\n if (typeof type === 'string') {\n return renderElement(type, props, inline);\n }\n\n return '';\n }\n\n function renderComponent(vnode: VNode): string {\n const {type, props} = vnode;\n const fn = type as Function;\n\n // Detect context Provider.\n // Root.js local JSX runtime: Provider._isProvider === true, Provider._context\n // is the Context object with a _stack array.\n // Preact >=10.27: Provider === Context (same function). `fn.__c` is the\n // context id string (e.g. \"__cC0\").\n // Preact <10.27: Provider._contextRef (mangled `fn.__`) points to the\n // context object which has `__c` (id) and `__` (default value).\n const fnAny = fn as any;\n if (fnAny._isProvider && fnAny._context) {\n const ctx = fnAny._context;\n ctx._stack.push((props as any).value);\n const result = renderChildren(props.children);\n ctx._stack.pop();\n return result;\n }\n let contextId: string | undefined;\n if (typeof fnAny.__c === 'string' && fnAny.__c.startsWith('__cC')) {\n contextId = fnAny.__c;\n } else if (fnAny.__ && typeof fnAny.__ === 'object' && fnAny.__.__c) {\n contextId = fnAny.__.__c;\n }\n if (contextId) {\n pushCtx(contextId, (props as any).value);\n const result = renderChildren(props.children);\n popCtx(contextId);\n return result;\n }\n\n // Detect context Consumer.\n if ((fn as any).contextType) {\n const ctx = (fn as any).contextType;\n const ctxId: string = ctx.__c;\n const stack = contextStacks.get(ctxId);\n const value =\n stack && stack.length > 0 ? stack[stack.length - 1] : ctx.__;\n if (typeof props.children === 'function') {\n return render(props.children(value));\n }\n return renderChildren(props.children);\n }\n\n // Regular component — set up a fake component instance so Preact hooks\n // (useContext, useState, useMemo, etc.) work during SSR.\n // Preact's useContext reads from `component.context[context.__c]`.\n const component: any = {\n props,\n context: buildGlobalContext(),\n state: {},\n __v: vnode, // _vnode\n __d: false, // _dirty\n __h: [], // _renderCallbacks\n __s: {}, // _nextState\n __H: null, // _hooks (initialised by hooks addon)\n };\n (vnode as any).__c = component;\n\n // Trigger Preact option hooks so the hooks addon can set currentComponent.\n (preactOptions as any).__b?.(vnode);\n (preactOptions as any).__r?.(vnode);\n\n try {\n // Class component.\n if (fn.prototype && fn.prototype.render) {\n const instance = new (fn as any)(props, component.context);\n instance.__n = component.__n;\n instance.__H = component.__H;\n (vnode as any).__c = instance;\n (preactOptions as any).__r?.(vnode);\n return render(instance.render(instance.props, instance.state));\n }\n\n // Functional component.\n const rendered = fn(props, component.context);\n return render(rendered);\n } finally {\n preactOptions.diffed?.(vnode as any);\n }\n }\n\n function renderElement(\n tag: string,\n props: Record<string, any>,\n inline?: boolean\n ): string {\n const isBlock = isPretty && !inline && blockSet.has(tag);\n const isVoid = VOID_ELEMENTS.has(tag);\n const attrs = renderAttrs(tag, props);\n let result = '<' + tag + attrs + '>';\n\n if (isVoid) {\n if (isBlock) result += '\\n';\n return result;\n }\n\n let inner = '';\n if (isDef(props?.dangerouslySetInnerHTML?.__html)) {\n inner = props.dangerouslySetInnerHTML.__html;\n } else if (isDef(props?.children)) {\n inner = renderChildren(props.children);\n } else if (tag === 'textarea' && props) {\n // For <textarea>, render value/defaultValue as text content since\n // browsers ignore the value attribute on textarea elements.\n const textVal = props.value ?? props.defaultValue;\n if (isDef(textVal)) {\n inner = escapeHtml(String(textVal));\n }\n }\n\n if (isBlock) {\n // When inner content contains block children (indicated by newlines),\n // add a newline after the opening tag so content starts on its own line.\n // Exempt raw-content elements (pre, textarea, script, style) where\n // newlines are literal text, not block-child indicators.\n const hasBlockChildren =\n !RAW_CONTENT_ELEMENTS.has(tag) && inner.includes('\\n');\n if (hasBlockChildren) {\n result += '\\n' + inner + '</' + tag + '>\\n';\n } else {\n result += inner + '</' + tag + '>\\n';\n }\n } else {\n result += inner + '</' + tag + '>';\n }\n\n return result;\n }\n\n function renderAttrs(tag: string, props: Record<string, any>): string {\n if (!props) return '';\n const parts: string[] = [];\n for (const key in props) {\n if (\n key === 'children' ||\n key === 'dangerouslySetInnerHTML' ||\n key === 'key' ||\n key === 'ref' ||\n key === '__self' ||\n key === '__source'\n ) {\n continue;\n }\n // Skip value/defaultValue on textarea — rendered as text content.\n if (tag === 'textarea' && (key === 'value' || key === 'defaultValue')) {\n continue;\n }\n // Skip event handlers.\n if (key.length > 2 && key[0] === 'o' && key[1] === 'n') continue;\n\n let value = props[key];\n if (!isDef(value)) continue;\n // For standard and boolean attributes, `false` removes the attribute.\n // For data-* attributes, `false` is rendered as the string \"false\".\n if (value === false && !key.startsWith('data-')) continue;\n\n const attrName = PROP_TO_ATTR[key] || key;\n\n // Boolean attributes.\n if (value === true) {\n parts.push(' ', attrName);\n continue;\n }\n\n // Style objects.\n if (key === 'style' && typeof value === 'object') {\n value = styleToString(value);\n if (!value) continue;\n }\n\n parts.push(' ', attrName, '=\"', escapeAttr(String(value)), '\"');\n }\n return parts.join('');\n }\n\n /**\n * Returns true if a child node is a text-like value (string, number).\n */\n function isTextNode(child: any): boolean {\n if (!isDef(child) || typeof child === 'boolean') return false;\n return (\n typeof child === 'string' ||\n typeof child === 'number' ||\n typeof child === 'bigint'\n );\n }\n\n /**\n * Checks if an array of children contains a mix of text nodes and elements.\n * When mixed, block elements should render inline to avoid breaking text flow.\n */\n function hasMixedContent(children: any[]): boolean {\n let hasText = false;\n let hasElement = false;\n for (const child of children) {\n if (isTextNode(child)) {\n hasText = true;\n } else if (isDef(child) && typeof child === 'object' && 'type' in child) {\n hasElement = true;\n }\n if (hasText && hasElement) return true;\n }\n return false;\n }\n\n function renderChildren(children: any): string {\n if (!isDef(children)) return '';\n if (Array.isArray(children)) {\n const inline = isPretty && hasMixedContent(children);\n return children.map((child) => render(child, inline)).join('');\n }\n return render(children);\n }\n\n return render(vnode);\n}\n\nfunction noop() {}\n"],"mappings":";;;;;AAAA,SAAQ,WAAW,qBAAoB;AAIvC,IAAM,gBAAgB,oBAAI,IAAI;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;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AAQ,WAAW,OAAO,UAAU,UAAU;AAChD,gBAAQ,cAAc,KAAK;AAC3B,YAAI,CAAC,MAAO;AAAA,MACd;AAEA,YAAM,KAAK,KAAK,UAAU,MAAM,WAAW,OAAO,KAAK,CAAC,GAAG,GAAG;AAAA,IAChE;AACA,WAAO,MAAM,KAAK,EAAE;AAAA,EACtB;AAKA,WAAS,WAAW,OAAqB;AACvC,QAAI,CAAC,MAAM,KAAK,KAAK,OAAO,UAAU,UAAW,QAAO;AACxD,WACE,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU;AAAA,EAErB;AAMA,WAAS,gBAAgB,UAA0B;AACjD,QAAI,UAAU;AACd,QAAI,aAAa;AACjB,eAAW,SAAS,UAAU;AAC5B,UAAI,WAAW,KAAK,GAAG;AACrB,kBAAU;AAAA,MACZ,WAAW,MAAM,KAAK,KAAK,OAAO,UAAU,YAAY,UAAU,OAAO;AACvE,qBAAa;AAAA,MACf;AACA,UAAI,WAAW,WAAY,QAAO;AAAA,IACpC;AACA,WAAO;AAAA,EACT;AAEA,WAAS,eAAe,UAAuB;AAC7C,QAAI,CAAC,MAAM,QAAQ,EAAG,QAAO;AAC7B,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,YAAM,SAAS,YAAY,gBAAgB,QAAQ;AACnD,aAAO,SAAS,IAAI,CAAC,UAAU,OAAO,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE;AAAA,IAC/D;AACA,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,SAAO,OAAO,KAAK;AACrB;AAEA,SAAS,OAAO;AAAC;","names":["vnode"]}
@@ -1,73 +0,0 @@
1
- // src/jsx/jsx-runtime.ts
2
- var options = {};
3
- function Fragment(props) {
4
- return props.children;
5
- }
6
- function jsx(type, props, key) {
7
- const resolvedKey = key !== void 0 ? key : props.key ?? null;
8
- const vnode = {
9
- type,
10
- props,
11
- key: resolvedKey
12
- };
13
- if (props.key !== void 0) {
14
- const { key: _, ...rest } = props;
15
- vnode.props = rest;
16
- }
17
- if (options.vnode) {
18
- options.vnode(vnode);
19
- }
20
- return vnode;
21
- }
22
- function createElement(type, props, ...children) {
23
- const normalizedProps = { ...props || {} };
24
- if (children.length === 1) {
25
- normalizedProps.children = children[0];
26
- } else if (children.length > 1) {
27
- normalizedProps.children = children;
28
- }
29
- const vnode = {
30
- type,
31
- props: normalizedProps,
32
- key: normalizedProps.key ?? null
33
- };
34
- if (normalizedProps.key !== void 0) {
35
- delete normalizedProps.key;
36
- }
37
- if (options.vnode) {
38
- options.vnode(vnode);
39
- }
40
- return vnode;
41
- }
42
- function createContext(defaultValue) {
43
- const ctx = {
44
- _defaultValue: defaultValue,
45
- _stack: [],
46
- Provider: null
47
- };
48
- const Provider = () => {
49
- return null;
50
- };
51
- Provider.displayName = "ContextProvider";
52
- Provider._isProvider = true;
53
- Provider._context = ctx;
54
- ctx.Provider = Provider;
55
- return ctx;
56
- }
57
- function useContext(context) {
58
- const stack = context._stack;
59
- if (stack.length > 0) {
60
- return stack[stack.length - 1];
61
- }
62
- return context._defaultValue;
63
- }
64
-
65
- export {
66
- options,
67
- Fragment,
68
- jsx,
69
- createElement,
70
- createContext,
71
- useContext
72
- };
73
- //# sourceMappingURL=chunk-CY5IQ4AQ.js.map