@cossackframework/renderer 0.8.2 → 0.9.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.
@@ -1,5 +1,6 @@
1
1
  export declare class LiveResult {
2
2
  readonly value: unknown;
3
+ private readonly __cossackDirectiveBrand;
3
4
  constructor(value: unknown);
4
5
  }
5
6
  export declare class RepeatResult<T = unknown> {
@@ -16,15 +17,18 @@ export declare class KeyResult {
16
17
  export declare class BindResult {
17
18
  readonly component: unknown;
18
19
  readonly fieldName: string;
20
+ private readonly __cossackDirectiveBrand;
19
21
  constructor(component: unknown, fieldName: string);
20
22
  }
21
23
  export declare class PreventDefaultResult {
22
24
  readonly handler: EventListener;
23
25
  readonly novalidate: boolean;
26
+ private readonly __cossackDirectiveBrand;
24
27
  constructor(handler: EventListener, novalidate: boolean);
25
28
  }
26
29
  export declare class IfDefinedResult {
27
30
  readonly value: unknown;
31
+ private readonly __cossackDirectiveBrand;
28
32
  constructor(value: unknown);
29
33
  }
30
34
  export declare class GuardResult {
package/dist/index.js CHANGED
@@ -3,6 +3,6 @@ import { isComponentResult as e } from "./component.js";
3
3
  import { CSSResult as t, css as n, unsafeCSS as r } from "./css.js";
4
4
  import { CossackElement as i, instanceStack as a, popCurrentInstance as o, pushCurrentInstance as s } from "./cossack-element.js";
5
5
  import { BindResult as c, CacheResult as l, GuardResult as u, IfDefinedResult as d, KeyResult as f, LiveResult as p, PreventDefaultResult as m, RepeatResult as h, bind as g, cache as _, choose as v, classMap as y, guard as b, ifDefined as x, join as S, key as C, live as w, map as T, preventDefault as E, range as D, repeat as O, resolveField as k, setField as A, styleMap as j, when as M } from "./directives.js";
6
- import { TemplateResult as N, UnsafeHTMLResult as P, component as F, escapeHtml as I, html as L, hydrate as R, isTemplateResult as z, isUnsafeHTML as B, nothing as V, render as H, renderToString as U, svg as W, unsafeHTML as G } from "./cossack-html.js";
7
- import { createContext as K } from "./context.js";
8
- export { c as BindResult, t as CSSResult, l as CacheResult, i as CossackElement, u as GuardResult, d as IfDefinedResult, f as KeyResult, p as LiveResult, m as PreventDefaultResult, h as RepeatResult, N as TemplateResult, P as UnsafeHTMLResult, g as bind, _ as cache, v as choose, y as classMap, F as component, K as createContext, n as css, I as escapeHtml, b as guard, L as html, R as hydrate, x as ifDefined, a as instanceStack, e as isComponentResult, z as isTemplateResult, B as isUnsafeHTML, S as join, C as key, w as live, T as map, V as nothing, o as popCurrentInstance, E as preventDefault, s as pushCurrentInstance, D as range, H as render, U as renderToString, O as repeat, k as resolveField, A as setField, j as styleMap, W as svg, r as unsafeCSS, G as unsafeHTML, M as when };
6
+ import { TemplateResult as N, UnsafeHTMLResult as P, captureRenderDrafts as F, component as I, escapeHtml as L, html as R, hydrate as z, isTemplateResult as B, isUnsafeHTML as V, nothing as H, render as U, renderToString as W, svg as G, unsafeHTML as K } from "./cossack-html.js";
7
+ import { createContext as q } from "./context.js";
8
+ export { c as BindResult, t as CSSResult, l as CacheResult, i as CossackElement, u as GuardResult, d as IfDefinedResult, f as KeyResult, p as LiveResult, m as PreventDefaultResult, h as RepeatResult, N as TemplateResult, P as UnsafeHTMLResult, g as bind, _ as cache, F as captureRenderDrafts, v as choose, y as classMap, I as component, q as createContext, n as css, L as escapeHtml, b as guard, R as html, z as hydrate, x as ifDefined, a as instanceStack, e as isComponentResult, B as isTemplateResult, V as isUnsafeHTML, S as join, C as key, w as live, T as map, H as nothing, o as popCurrentInstance, E as preventDefault, s as pushCurrentInstance, D as range, U as render, W as renderToString, O as repeat, k as resolveField, A as setField, j as styleMap, G as svg, r as unsafeCSS, K as unsafeHTML, M as when };
@@ -20,7 +20,7 @@ function i(t) {
20
20
  let r = [];
21
21
  return {
22
22
  html: t.replace(e, (e) => {
23
- let t = e.replace(n, "");
23
+ let t = e.replace(/^<(?:[^>"']|"[^"]*"|'[^']*')*>/, (e) => e.replace(n, ""));
24
24
  return r.push(t), `\x00PRESERVE_${r.length - 1}\x00`;
25
25
  }),
26
26
  blocks: r
@@ -31,7 +31,7 @@ function a(e, t) {
31
31
  }
32
32
  function o(e) {
33
33
  let { html: o, blocks: s } = i(e), c = o.replace(/<!--(?!\[if\s|\/?CRP|CSA-[SE])[\s\S]*?-->/g, "");
34
- return c = c.replace(n, ""), c = c.replace(/\s+/g, " "), c = c.replace(/>\s+</g, "><"), c = c.replace(r, (e, t, n, r) => r === "/>" ? e : `${t}=${n}`), c = c.replace(t, (e, t, n) => `<${t}${n ? n.trimEnd() : ""}>`), c = a(c, s), c = c.replace(/>\s+</g, "><"), c = c.trim(), c;
34
+ return c = c.replace(n, ""), c = c.replace(/\s+/g, " "), c = c.replace(/>\s+</g, "><"), c = c.replace(r, (e, t, n, r) => r === "/>" ? e : `${t}=${n}`), c = c.replace(t, (e, t, n) => `<${t}${n ? n.trimEnd() : ""}>`), c = c.replace(/(>|\x00PRESERVE_\d+\x00)\s+(?=<|\x00PRESERVE_\d+\x00)/g, "$1"), c = a(c, s), c = c.trim(), c;
35
35
  }
36
36
  //#endregion
37
37
  export { o as minifyHtml };
@@ -0,0 +1,2 @@
1
+ /** Convert temporary property attributes without reserializing authored markup or hydration markers. */
2
+ export declare const serializeFormValues: (source: string) => string;
@@ -0,0 +1,71 @@
1
+ // @ts-self-types="./ssr-form-values.d.ts"
2
+ import { parseFragment as e } from "parse5";
3
+ //#region src/ssr-form-values.ts
4
+ var t = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), n = (n) => {
5
+ if (!n.includes(" .value=")) return n;
6
+ let r = e(n, { sourceCodeLocationInfo: !0 }), i = [], a = (e) => "tagName" in e && e.tagName === "script" ? "" : e.nodeName === "#text" ? e.value : "childNodes" in e ? e.childNodes.map(a).join("") : "", o = (e) => {
7
+ if ("tagName" in e) {
8
+ let n = e.attrs.find((e) => e.name === ".value"), r = e.sourceCodeLocation, s = r?.attrs?.[".value"];
9
+ if (n && s) {
10
+ let o = e.namespaceURI === "http://www.w3.org/1999/xhtml";
11
+ if (o && e.tagName === "textarea" && r?.startTag) {
12
+ i.push({
13
+ start: s.startOffset,
14
+ end: s.endOffset,
15
+ text: ""
16
+ });
17
+ let e = t(n.value);
18
+ i.push({
19
+ start: r.startTag.endOffset,
20
+ end: r.endTag?.startOffset ?? r.endOffset,
21
+ text: (e.startsWith("\n") ? "\n" : "") + e
22
+ });
23
+ } else if (o && e.tagName === "select") {
24
+ i.push({
25
+ start: s.startOffset,
26
+ end: s.endOffset,
27
+ text: ""
28
+ });
29
+ let t = !1, r = (e) => {
30
+ if ("tagName" in e && e.tagName === "option") {
31
+ let r = e.attrs.find((e) => e.name === ".value")?.value ?? e.attrs.find((e) => e.name === "value")?.value ?? a(e).replace(/[\t\n\f\r ]+/g, " ").replace(/^ | $/g, ""), o = !t && r === n.value;
32
+ t ||= o;
33
+ let s = e.sourceCodeLocation?.attrs?.selected;
34
+ s && i.push({
35
+ start: s.startOffset,
36
+ end: s.endOffset,
37
+ text: ""
38
+ });
39
+ let c = e.sourceCodeLocation?.startTag?.endOffset;
40
+ o && c !== void 0 && i.push({
41
+ start: c - 1,
42
+ end: c - 1,
43
+ text: " selected"
44
+ });
45
+ }
46
+ "childNodes" in e && e.childNodes.forEach(r);
47
+ };
48
+ e.childNodes.forEach(r);
49
+ } else {
50
+ let e = r?.attrs?.value;
51
+ e && i.push({
52
+ start: e.startOffset,
53
+ end: e.endOffset,
54
+ text: ""
55
+ }), i.push({
56
+ start: s.startOffset,
57
+ end: s.startOffset + 6,
58
+ text: "value"
59
+ });
60
+ }
61
+ }
62
+ e.tagName === "template" && "content" in e && o(e.content);
63
+ }
64
+ "childNodes" in e && e.childNodes.forEach(o);
65
+ };
66
+ o(r), i.sort((e, t) => t.start - e.start || t.end - e.end);
67
+ for (let e of i) n = n.slice(0, e.start) + e.text + n.slice(e.end);
68
+ return n;
69
+ };
70
+ //#endregion
71
+ export { n as serializeFormValues };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cossackframework/renderer",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "The rendering engine for Cossack Framework. Lit inspired, light dom, ssr",
@@ -14,11 +14,16 @@
14
14
  "module": "./dist/index.js",
15
15
  "types": "./dist/index.d.ts",
16
16
  "files": [
17
- "dist"
17
+ "dist",
18
+ "agent-docs.json"
18
19
  ],
19
20
  "exports": {
20
21
  ".": {
21
22
  "types": "./dist/index.d.ts",
23
+ "workerd": "./dist/index.js",
24
+ "worker": "./dist/index.js",
25
+ "node": "./dist/index.js",
26
+ "browser": "./dist/browser.js",
22
27
  "import": "./dist/index.js"
23
28
  },
24
29
  "./server": {
@@ -30,14 +35,15 @@
30
35
  "access": "public"
31
36
  },
32
37
  "dependencies": {
33
- "css-tree": "^3.2.1"
38
+ "css-tree": "^3.2.1",
39
+ "parse5": "8.0.1"
34
40
  },
35
41
  "devDependencies": {
36
42
  "happy-dom": "^20.11.1",
37
43
  "oxlint": "^1.41.0",
38
44
  "typescript": "^7.0.2",
39
45
  "vite": "^8.1.4",
40
- "vitest": "^4.1.10"
46
+ "vitest": "^4.1.11"
41
47
  },
42
48
  "scripts": {
43
49
  "build": "vite build && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-declaration-imports.mjs dist",