@jay-framework/ssr-runtime 0.24.6 → 0.25.0

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
@@ -10,6 +10,14 @@ declare function escapeHtml(str: string): string;
10
10
  */
11
11
  declare function escapeAttr(str: string): string;
12
12
 
13
+ /**
14
+ * Join CSS class names, dropping falsy values (empty strings left by unmatched
15
+ * conditional classes, plus null / undefined / false). Compiler-generated class
16
+ * expressions call this so a false conditional class never leaves stray, double,
17
+ * or trailing whitespace in the resulting `class` attribute.
18
+ */
19
+ declare function classNames(...parts: Array<string | false | null | undefined>): string;
20
+
13
21
  /**
14
22
  * Context passed to compiled renderToStream functions.
15
23
  * Provides `write` for streaming HTML chunks and `onAsync` for registering
@@ -40,4 +48,4 @@ interface ServerRenderContext {
40
48
  */
41
49
  declare function asyncSwapScript(id: string, html: string): string;
42
50
 
43
- export { type ServerRenderContext, asyncSwapScript, escapeAttr, escapeHtml };
51
+ export { type ServerRenderContext, asyncSwapScript, classNames, escapeAttr, escapeHtml };
package/dist/index.js CHANGED
@@ -12,12 +12,16 @@ function escapeHtml(str) {
12
12
  function escapeAttr(str) {
13
13
  return String(str).replace(HTML_ESCAPE_RE, (char) => HTML_ESCAPE_MAP[char]);
14
14
  }
15
+ function classNames(...parts) {
16
+ return parts.filter(Boolean).join(" ");
17
+ }
15
18
  function asyncSwapScript(id, html) {
16
19
  const escapedHtml = html.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
17
20
  return `<script>(function(){var t=document.querySelector('[jay-async="${id}:pending"]');if(t){var d=document.createElement('div');d.innerHTML='${escapedHtml}';t.replaceWith(d.firstChild);}window.__jay&&window.__jay.hydrateAsync&&window.__jay.hydrateAsync('${id}');})()<\/script>`;
18
21
  }
19
22
  export {
20
23
  asyncSwapScript,
24
+ classNames,
21
25
  escapeAttr,
22
26
  escapeHtml
23
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jay-framework/ssr-runtime",
3
- "version": "0.24.6",
3
+ "version": "0.25.0",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "test:watch": "vitest"
21
21
  },
22
22
  "devDependencies": {
23
- "@jay-framework/dev-environment": "^0.24.6",
23
+ "@jay-framework/dev-environment": "^0.25.0",
24
24
  "@types/node": "^20.11.5",
25
25
  "rimraf": "^5.0.5",
26
26
  "tsup": "^8.0.1",