@cossackframework/renderer 0.8.0 → 0.8.2

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,4 +1,4 @@
1
- import { CossackElement } from './cossack-element';
1
+ import { CossackElement } from './cossack-element.js';
2
2
  export interface ComponentResult {
3
3
  _type: 'COMPONENT';
4
4
  clazz: new () => CossackElement;
package/dist/component.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./component.d.ts"
1
2
  //#region src/component.ts
2
3
  var e = (e) => typeof e == "object" && !!e && e._type === "COMPONENT";
3
4
  //#endregion
package/dist/context.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./context.d.ts"
1
2
  //#region src/context.ts
2
3
  function e(e) {
3
4
  return {
@@ -1,6 +1,6 @@
1
- import { TemplateResult } from './cossack-html';
2
- import { Context } from './context';
3
- import type { CSSResultGroup } from './css';
1
+ import { TemplateResult } from './cossack-html.js';
2
+ import { Context } from './context.js';
3
+ import type { CSSResultGroup } from './css.js';
4
4
  export type PropertyDeclaration = {
5
5
  type?: unknown;
6
6
  reflect?: boolean;
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./cossack-element.d.ts"
1
2
  import { getFinalizedStyles as e } from "./css.js";
2
3
  import { TemplateResult as t, html as n, hydrate as r, isTemplateResult as i, render as a } from "./cossack-html.js";
3
4
  //#region src/cossack-element.ts
@@ -1,4 +1,4 @@
1
- import { CossackElement } from './cossack-element';
1
+ import { CossackElement } from './cossack-element.js';
2
2
  export type TemplateResultType = 1 | 2;
3
3
  export declare class TemplateResult<T extends TemplateResultType = TemplateResultType> {
4
4
  readonly strings: TemplateStringsArray;
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./cossack-html.d.ts"
1
2
  import { isComponentResult as e } from "./component.js";
2
3
  import { CossackElement as t, popCurrentInstance as n, pushCurrentInstance as r } from "./cossack-element.js";
3
4
  import { BindResult as i, CacheResult as a, GuardResult as o, IfDefinedResult as s, KeyResult as c, LiveResult as l, PreventDefaultResult as u, RepeatResult as d, resolveField as f, setField as p } from "./directives.js";
@@ -334,7 +335,7 @@ var m = class {
334
335
  if (t) if (t = !1, y(e)) try {
335
336
  this._adoptTemplate(e);
336
337
  } catch (t) {
337
- if (t instanceof U) this.clear(), this._clearTemplateCache(), this.updateNode(e);
338
+ if (t instanceof W) this.clear(), this._clearTemplateCache(), this.updateNode(e);
338
339
  else throw t;
339
340
  }
340
341
  else e == null ? this.clear() : this.updateNode(e);
@@ -345,8 +346,8 @@ var m = class {
345
346
  Object.assign(r, e.props), "props" in r && (r.props = e.props), r.children = e.children, r.requestUpdate();
346
347
  }
347
348
  _adoptSequence(e, t) {
348
- let r = K(this._nodesBetween());
349
- if (r.length !== e.length) throw new U(`sequence length mismatch: SSR has ${r.length} items, client has ${e.length}`);
349
+ let r = q(this._nodesBetween());
350
+ if (r.length !== e.length) throw new W(`sequence length mismatch: SSR has ${r.length} items, client has ${e.length}`);
350
351
  this._childParts = [], this._partKeys = t ? [] : this._partKeys;
351
352
  for (let i = 0; i < e.length; i++) {
352
353
  let [a, o] = r[i], s = new n(a, o);
@@ -354,8 +355,8 @@ var m = class {
354
355
  }
355
356
  }
356
357
  _adoptTemplate(e) {
357
- let { fragment: t, parts: n } = V(e), r = this._nodesBetween(), i = /* @__PURE__ */ new Map();
358
- q(t.childNodes, r, i), J(n, i);
358
+ let { fragment: t, parts: n } = H(e), r = this._nodesBetween(), i = /* @__PURE__ */ new Map();
359
+ J(t.childNodes, r, i), Y(n, i);
359
360
  for (let t = 0; t < e.values.length; t++) n[t] && n[t].update(e.values[t]);
360
361
  this._cachedTemplateIdentity = F(e), this._cachedParts = n;
361
362
  }
@@ -473,8 +474,8 @@ var m = class {
473
474
  else {
474
475
  this._clearTemplateCache(), this.clear();
475
476
  let e = document.createDocumentFragment();
476
- H(t, e), this.startNode.parentNode.insertBefore(e, this.endNode);
477
- let n = B.get(e.firstChild?.childNodes[0] || e);
477
+ U(t, e), this.startNode.parentNode.insertBefore(e, this.endNode);
478
+ let n = V.get(e.firstChild?.childNodes[0] || e);
478
479
  n && (this._cachedTemplateIdentity = n.identity, this._cachedParts = n.parts);
479
480
  }
480
481
  else if (S(t)) {
@@ -484,7 +485,7 @@ var m = class {
484
485
  } else if (e(t) || typeof t == "object" && t && !(t instanceof Node) && !Array.isArray(t)) {
485
486
  this._clearTemplateCache(), this.clear();
486
487
  let e = document.createDocumentFragment();
487
- H(h`${t}`, e), this.startNode.parentNode.insertBefore(e, this.endNode);
488
+ U(h`${t}`, e), this.startNode.parentNode.insertBefore(e, this.endNode);
488
489
  } else if (t instanceof Node) this._clearTemplateCache(), this.clear(), this.startNode.parentNode.insertBefore(t, this.endNode);
489
490
  else if (t === _ || t === "" || t == null || t === !1) this._clearTemplateCache(), this.clear();
490
491
  else {
@@ -574,9 +575,9 @@ var m = class {
574
575
  (!o || o.lastKind !== "checked" || o.lastValue !== e) && (r.checked = e);
575
576
  } else {
576
577
  let e = a == null ? "" : String(a);
577
- (!o || o.lastKind !== "value" || String(o.lastValue) !== e) && (r.value = e);
578
+ (!o || o.lastKind !== "value" || String(o.lastValue) !== e || this.element instanceof HTMLSelectElement && r.value !== e) && (r.value = e);
578
579
  }
579
- let s = z(this.element, t), c = !!o && (o.boundComponent !== i || o.boundField !== n.fieldName || o.listener.__eventName !== s);
580
+ let s = B(this.element, t), c = !!o && (o.boundComponent !== i || o.boundField !== n.fieldName || o.listener.__eventName !== s);
580
581
  if (o && c && (this.element.removeEventListener(o.listener.__eventName, o.listener), this.bindStates.delete(e), o = void 0), o) o.lastKind = t, o.lastValue = t === "checked" ? !!a : a == null ? "" : String(a);
581
582
  else {
582
583
  let r = (e) => {
@@ -589,7 +590,7 @@ var m = class {
589
590
  lastValue: t === "checked" ? !!a : a == null ? "" : String(a),
590
591
  boundComponent: i,
591
592
  boundField: n.fieldName
592
- }, this.bindStates.set(e, o);
593
+ }, this.bindStates.set(e, o), t === "value" && z(this.element, () => this.bindStates.get(e) === o, () => f(o.boundComponent, o.boundField));
593
594
  }
594
595
  }
595
596
  }, R = class {
@@ -700,19 +701,28 @@ var m = class {
700
701
  (this.lastFormKind !== "checked" || this.lastFormValue !== e) && (n.checked = e, this.lastFormValue = e, this.lastFormKind = "checked");
701
702
  } else {
702
703
  let e = i == null ? "" : String(i);
703
- (this.lastFormKind !== "value" || String(this.lastFormValue) !== e) && (n.value = e, this.lastFormValue = e, this.lastFormKind = "value");
704
+ (this.lastFormKind !== "value" || String(this.lastFormValue) !== e || this.element instanceof HTMLSelectElement && n.value !== e) && (n.value = e, this.lastFormValue = e, this.lastFormKind = "value");
704
705
  }
705
- let a = z(this.element, t);
706
+ let a = B(this.element, t);
706
707
  if (this.bindListener && (this.boundPropName !== t || this.boundComponent !== r || this.boundFieldName !== e.fieldName || this.bindListener.__eventName !== a) && this._detachBindListener(), !this.bindListener) {
707
708
  let n = (n) => {
708
709
  let i = n.currentTarget, a = t === "checked" ? !!i[t] : i[t];
709
710
  r && p(r, e.fieldName, a);
710
711
  };
711
- n.__eventName = a, this.bindListener = n, this.boundPropName = t, this.boundComponent = r, this.boundFieldName = e.fieldName, this.element.addEventListener(a, n);
712
+ if (n.__eventName = a, this.bindListener = n, this.boundPropName = t, this.boundComponent = r, this.boundFieldName = e.fieldName, this.element.addEventListener(a, n), t === "value") {
713
+ let e = n;
714
+ z(this.element, () => this.bindListener === e, () => f(this.boundComponent, this.boundFieldName));
715
+ }
712
716
  }
713
717
  this.element.hasAttribute(this.name) && this.element.removeAttribute(this.name);
714
718
  }
715
- }, z = (e, t) => {
719
+ }, z = (e, t, n) => {
720
+ e instanceof HTMLSelectElement && queueMicrotask(() => {
721
+ if (!t()) return;
722
+ let r = n(), i = r == null ? "" : String(r);
723
+ e.value !== i && (e.value = i);
724
+ });
725
+ }, B = (e, t) => {
716
726
  if (e instanceof HTMLSelectElement) return "change";
717
727
  if (e instanceof HTMLTextAreaElement) return "input";
718
728
  if (e instanceof HTMLInputElement) {
@@ -720,7 +730,7 @@ var m = class {
720
730
  return t === "checked" || n === "checkbox" || n === "radio" || n === "range" ? "change" : "input";
721
731
  }
722
732
  return "input";
723
- }, B = /* @__PURE__ */ new WeakMap(), V = (e) => {
733
+ }, V = /* @__PURE__ */ new WeakMap(), H = (e) => {
724
734
  let t = [], n = A(e.strings, e.__cossackScope), r = "", i = !1, a = null, o = /(\.\.\.|[.@?]?[a-zA-Z0-9_:-]+)=["']?$/;
725
735
  for (let e = 0; e < n.length - 1; e++) {
726
736
  let t = n[e];
@@ -789,8 +799,8 @@ var m = class {
789
799
  fragment: l,
790
800
  parts: t
791
801
  };
792
- }, H = (e, t) => {
793
- let n = B.get(t), r = F(e);
802
+ }, U = (e, t) => {
803
+ let n = V.get(t), r = F(e);
794
804
  if (n && n.identity === r) {
795
805
  n.parts.forEach((t, n) => {
796
806
  t.update(e.values[n]);
@@ -798,22 +808,22 @@ var m = class {
798
808
  return;
799
809
  }
800
810
  if (n) for (let e of n.parts) e && typeof e.dispose == "function" && e.dispose();
801
- let { fragment: i, parts: a } = V(e), o = e.values;
811
+ let { fragment: i, parts: a } = H(e), o = e.values;
802
812
  for (let e = 0; e < o.length; e++) a[e] && a[e].update(o[e]);
803
813
  if (typeof HTMLElement < "u" && t instanceof HTMLElement || typeof ShadowRoot < "u" && t instanceof ShadowRoot) t.innerHTML = "";
804
814
  else for (; t.firstChild;) t.removeChild(t.firstChild);
805
- t.appendChild(i), B.set(t, {
815
+ t.appendChild(i), V.set(t, {
806
816
  identity: r,
807
817
  parts: a
808
818
  });
809
- }, U = class extends Error {}, W = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? `<${e.nodeName.toLowerCase()}>` : e.nodeType === Node.COMMENT_NODE ? `<!--${e.nodeValue}-->` : e.nodeType === Node.TEXT_NODE ? `text"${(e.nodeValue || "").slice(0, 30)}"` : `nodeType:${e.nodeType}` : "<none>", G = (e) => {
819
+ }, W = class extends Error {}, G = (e) => e ? e.nodeType === Node.ELEMENT_NODE ? `<${e.nodeName.toLowerCase()}>` : e.nodeType === Node.COMMENT_NODE ? `<!--${e.nodeValue}-->` : e.nodeType === Node.TEXT_NODE ? `text"${(e.nodeValue || "").slice(0, 30)}"` : `nodeType:${e.nodeType}` : "<none>", K = (e) => {
810
820
  if (e.nodeType === Node.TEXT_NODE) return (e.nodeValue || "").trim() === "";
811
821
  if (e.nodeType === Node.COMMENT_NODE) {
812
822
  let t = e.nodeValue || "";
813
823
  return !/^CRP_\d+$/.test(t) && t !== "/CRP" && t !== "CSA-S" && t !== "CSA-E";
814
824
  }
815
825
  return !1;
816
- }, K = (e) => {
826
+ }, q = (e) => {
817
827
  let t = [], n = [];
818
828
  for (let r of e) {
819
829
  if (r.nodeType !== Node.COMMENT_NODE) continue;
@@ -825,19 +835,19 @@ var m = class {
825
835
  }
826
836
  }
827
837
  return t;
828
- }, q = (e, t, n) => {
838
+ }, J = (e, t, n) => {
829
839
  let r = 0;
830
840
  for (let i = 0; i < e.length; i++) {
831
841
  let a = e[i];
832
- if (G(a)) continue;
833
- for (; r < t.length && G(t[r]);) r++;
842
+ if (K(a)) continue;
843
+ for (; r < t.length && K(t[r]);) r++;
834
844
  let o = t[r];
835
- if (!o) throw new U(`existing shorter than blueprint (expected ${W(a)})`);
845
+ if (!o) throw new W(`existing shorter than blueprint (expected ${G(a)})`);
836
846
  if (a.nodeType === Node.ELEMENT_NODE) {
837
- if (o.nodeType !== Node.ELEMENT_NODE || a.nodeName !== o.nodeName || a.namespaceURI !== o.namespaceURI) throw new U(`tag mismatch: blueprint ${W(a)} vs existing ${W(o)}`);
838
- n.set(a, o), q(a.childNodes, Array.from(o.childNodes), n);
847
+ if (o.nodeType !== Node.ELEMENT_NODE || a.nodeName !== o.nodeName || a.namespaceURI !== o.namespaceURI) throw new W(`tag mismatch: blueprint ${G(a)} vs existing ${G(o)}`);
848
+ n.set(a, o), J(a.childNodes, Array.from(o.childNodes), n);
839
849
  } else {
840
- if (a.nodeType !== o.nodeType) throw new U(`type mismatch: blueprint ${W(a)} vs existing ${W(o)}`);
850
+ if (a.nodeType !== o.nodeType) throw new W(`type mismatch: blueprint ${G(a)} vs existing ${G(o)}`);
841
851
  n.set(a, o);
842
852
  }
843
853
  if (r++, a.nodeType === Node.COMMENT_NODE && /^CRP_\d+$/.test(a.nodeValue || "")) {
@@ -852,23 +862,23 @@ var m = class {
852
862
  }
853
863
  }
854
864
  }
855
- for (; r < t.length && G(t[r]);) r++;
856
- if (r < t.length) throw new U(`existing longer than blueprint (unexpected ${W(t[r])})`);
857
- }, J = (e, t) => {
865
+ for (; r < t.length && K(t[r]);) r++;
866
+ if (r < t.length) throw new W(`existing longer than blueprint (unexpected ${G(t[r])})`);
867
+ }, Y = (e, t) => {
858
868
  for (let n of e) if (n) {
859
869
  if (n instanceof I) {
860
870
  let e = t.get(n.startNode), r = t.get(n.endNode);
861
- if (!e || !r) throw new U("node part anchors not found");
871
+ if (!e || !r) throw new W("node part anchors not found");
862
872
  n.startNode = e, n.endNode = r, n._beginHydration();
863
873
  } else if (n instanceof R || n instanceof L) {
864
874
  let e = t.get(n.element);
865
- if (!e) throw new U("attribute part element not found");
875
+ if (!e) throw new W("attribute part element not found");
866
876
  n.element = e;
867
877
  }
868
878
  }
869
- }, Y = (e, t) => {
870
- if (!t.hasChildNodes()) return H(e, t);
871
- let n = B.get(t), r = F(e);
879
+ }, X = (e, t) => {
880
+ if (!t.hasChildNodes()) return U(e, t);
881
+ let n = V.get(t), r = F(e);
872
882
  if (n && n.identity === r) {
873
883
  n.parts.forEach((t, n) => t.update(e.values[n]));
874
884
  return;
@@ -876,19 +886,19 @@ var m = class {
876
886
  if (n) for (let e of n.parts) e && typeof e.dispose == "function" && e.dispose();
877
887
  let i;
878
888
  try {
879
- let { fragment: n, parts: r } = V(e);
889
+ let { fragment: n, parts: r } = H(e);
880
890
  i = r;
881
891
  let a = /* @__PURE__ */ new Map();
882
- q(n.childNodes, Array.from(t.childNodes), a), J(i, a);
892
+ J(n.childNodes, Array.from(t.childNodes), a), Y(i, a);
883
893
  for (let t = 0; t < e.values.length; t++) i[t] && i[t].update(e.values[t]);
884
894
  } catch (n) {
885
- if (n instanceof U) return console.warn("[cossack] hydration mismatch, falling back to render:", n.message), H(e, t);
895
+ if (n instanceof W) return console.warn("[cossack] hydration mismatch, falling back to render:", n.message), U(e, t);
886
896
  throw n;
887
897
  }
888
- B.set(t, {
898
+ V.set(t, {
889
899
  identity: r,
890
900
  parts: i
891
901
  });
892
902
  };
893
903
  //#endregion
894
- export { m as TemplateResult, b as UnsafeHTMLResult, v as component, C as escapeHtml, h as html, Y as hydrate, y as isTemplateResult, S as isUnsafeHTML, _ as nothing, H as render, N as renderToString, g as svg, x as unsafeHTML };
904
+ export { m as TemplateResult, b as UnsafeHTMLResult, v as component, C as escapeHtml, h as html, X as hydrate, y as isTemplateResult, S as isUnsafeHTML, _ as nothing, U as render, N as renderToString, g as svg, x as unsafeHTML };
package/dist/css.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./css.d.ts"
1
2
  import e from "css-tree/parser";
2
3
  import t from "css-tree/generator";
3
4
  import n from "css-tree/walker";
@@ -2,11 +2,11 @@ export declare class LiveResult {
2
2
  readonly value: unknown;
3
3
  constructor(value: unknown);
4
4
  }
5
- export declare class RepeatResult {
6
- readonly items: unknown[];
7
- readonly keyFn: (item: any, index: number) => unknown;
8
- readonly templateFn: (item: any, index: number) => unknown;
9
- constructor(items: unknown[], keyFn: (item: any, index: number) => unknown, templateFn: (item: any, index: number) => unknown);
5
+ export declare class RepeatResult<T = unknown> {
6
+ readonly items: readonly T[];
7
+ readonly keyFn: (item: T, index: number) => unknown;
8
+ readonly templateFn: (item: T, index: number) => unknown;
9
+ constructor(items: readonly T[], keyFn: (item: T, index: number) => unknown, templateFn: (item: T, index: number) => unknown);
10
10
  }
11
11
  export declare class KeyResult {
12
12
  readonly value: unknown;
@@ -45,7 +45,8 @@ export declare const live: (value: unknown) => LiveResult;
45
45
  * Repeats a template for each item in an array, using a key to maintain state.
46
46
  * Usage: repeat(items, (item) => item.id, (item) => html`...`)
47
47
  */
48
- export declare const repeat: (items: unknown[], keyFnOrTemplate: (item: any, index: number) => unknown, template?: (item: any, index: number) => unknown) => RepeatResult;
48
+ export declare function repeat<T>(items: readonly T[], template: (item: T, index: number) => unknown): RepeatResult<T>;
49
+ export declare function repeat<T>(items: readonly T[], keyFn: (item: T, index: number) => unknown, template: (item: T, index: number) => unknown): RepeatResult<T>;
49
50
  /**
50
51
  * Generates a class string from an object.
51
52
  * Usage: class="${classMap({ active: isActive })}"
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./directives.d.ts"
1
2
  //#region src/directives.ts
2
3
  var e = class {
3
4
  value;
@@ -45,7 +46,11 @@ var e = class {
45
46
  constructor(e) {
46
47
  this.value = e;
47
48
  }
48
- }, c = (t) => new e(t), l = (e, n, r) => r === void 0 ? new t(e, (e, t) => t, n) : new t(e, n, r), u = (e) => Object.keys(e).filter((t) => e[t]).join(" "), d = (e) => Object.keys(e).filter((t) => e[t] != null).map((t) => `${t}:${e[t]}`).join(";"), f = (e, t) => new n(e, t), p = (e, t) => new r(e, t);
49
+ }, c = (t) => new e(t);
50
+ function l(e, n, r) {
51
+ return r === void 0 ? new t(e, (e, t) => t, n) : new t(e, n, r);
52
+ }
53
+ var u = (e) => Object.keys(e).filter((t) => e[t]).join(" "), d = (e) => Object.keys(e).filter((t) => e[t] != null).map((t) => `${t}:${e[t]}`).join(";"), f = (e, t) => new n(e, t), p = (e, t) => new r(e, t);
49
54
  function m(e, t) {
50
55
  let n = e;
51
56
  if (!t.includes(".")) return n?.[t];
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- export * from './cossack-html';
2
- export * from './cossack-element';
3
- export * from './component';
4
- export * from './context';
5
- export * from './directives';
6
- export { css, unsafeCSS, CSSResult } from './css';
7
- export type { CSSResultGroup } from './css';
1
+ export * from './cossack-html.js';
2
+ export * from './cossack-element.js';
3
+ export * from './component.js';
4
+ export * from './context.js';
5
+ export * from './directives.js';
6
+ export { css, unsafeCSS, CSSResult } from './css.js';
7
+ export type { CSSResultGroup } from './css.js';
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./index.d.ts"
1
2
  import { isComponentResult as e } from "./component.js";
2
3
  import { CSSResult as t, css as n, unsafeCSS as r } from "./css.js";
3
4
  import { CossackElement as i, instanceStack as a, popCurrentInstance as o, pushCurrentInstance as s } from "./cossack-element.js";
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./minify-html.d.ts"
1
2
  //#region src/minify-html.ts
2
3
  var e = /<(script|style|pre|textarea)\b[^>]*>[\s\S]*?<\/\1>/gi, t = RegExp(`<(${[.../* @__PURE__ */ new Set([
3
4
  "area",
@@ -14,7 +15,7 @@ var e = /<(script|style|pre|textarea)\b[^>]*>[\s\S]*?<\/\1>/gi, t = RegExp(`<(${
14
15
  "source",
15
16
  "track",
16
17
  "wbr"
17
- ])].join("|")})(\\s[^>]*)?\\/\\s*>`, "gi"), n = /\s+type\s*=\s*["']text\/(javascript|css)["']/gi, r = /(\w[\w-]*)\s*=\s*["']([a-zA-Z0-9_.-]+)["'](?=\s|\/?>)/g;
18
+ ])].join("|")})(\\s[^>]*)?\\/\\s*>`, "gi"), n = /\s+type\s*=\s*["']text\/(javascript|css)["']/gi, r = /(\w[\w-]*)\s*=\s*["']([a-zA-Z0-9_.-]+)["'](?=(\s|\/?>))/g;
18
19
  function i(t) {
19
20
  let r = [];
20
21
  return {
@@ -30,7 +31,7 @@ function a(e, t) {
30
31
  }
31
32
  function o(e) {
32
33
  let { html: o, blocks: s } = i(e), c = o.replace(/<!--(?!\[if\s|\/?CRP|CSA-[SE])[\s\S]*?-->/g, "");
33
- return c = c.replace(n, ""), c = c.replace(/\s+/g, " "), c = c.replace(/>\s+</g, "><"), c = c.replace(r, (e, t, n) => `${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 = a(c, s), c = c.replace(/>\s+</g, "><"), c = c.trim(), c;
34
35
  }
35
36
  //#endregion
36
37
  export { o as minifyHtml };
package/dist/server.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { renderToString, escapeHtml } from './cossack-html';
2
- export { html, svg, nothing, TemplateResult } from './cossack-html';
3
- export type { SVGTemplateResult, ValueSanitizer, SanitizerFactory } from './cossack-html';
4
- export { css, unsafeCSS, CSSResult } from './css';
5
- export type { CSSResultGroup } from './css';
6
- export { minifyHtml } from './minify-html';
1
+ export { renderToString, escapeHtml } from './cossack-html.js';
2
+ export { html, svg, nothing, TemplateResult } from './cossack-html.js';
3
+ export type { SVGTemplateResult, ValueSanitizer, SanitizerFactory } from './cossack-html.js';
4
+ export { css, unsafeCSS, CSSResult } from './css.js';
5
+ export type { CSSResultGroup } from './css.js';
6
+ export { minifyHtml } from './minify-html.js';
package/dist/server.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-self-types="./server.d.ts"
1
2
  import { CSSResult as e, css as t, unsafeCSS as n } from "./css.js";
2
3
  import { TemplateResult as r, escapeHtml as i, html as a, nothing as o, renderToString as s, svg as c } from "./cossack-html.js";
3
4
  import { minifyHtml as l } from "./minify-html.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cossackframework/renderer",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "description": "The rendering engine for Cossack Framework. Lit inspired, light dom, ssr",
@@ -18,12 +18,12 @@
18
18
  ],
19
19
  "exports": {
20
20
  ".": {
21
- "import": "./dist/index.js",
22
- "types": "./dist/index.d.ts"
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js"
23
23
  },
24
24
  "./server": {
25
- "import": "./dist/server.js",
26
- "types": "./dist/server.d.ts"
25
+ "types": "./dist/server.d.ts",
26
+ "import": "./dist/server.js"
27
27
  }
28
28
  },
29
29
  "publishConfig": {
@@ -33,13 +33,14 @@
33
33
  "css-tree": "^3.2.1"
34
34
  },
35
35
  "devDependencies": {
36
+ "happy-dom": "^20.11.1",
36
37
  "oxlint": "^1.41.0",
37
38
  "typescript": "^7.0.2",
38
39
  "vite": "^8.1.4",
39
40
  "vitest": "^4.1.10"
40
41
  },
41
42
  "scripts": {
42
- "build": "vite build && tsc -p tsconfig.declarations.json",
43
+ "build": "vite build && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-declaration-imports.mjs dist",
43
44
  "test": "vitest",
44
45
  "lint": "oxlint"
45
46
  }