@cossackframework/renderer 0.7.0 → 0.7.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.
- package/README.md +103 -1
- package/dist/component.d.ts +4 -0
- package/dist/cossack-element.d.ts +10 -0
- package/dist/cossack-html-CnATUTdE.js +8166 -0
- package/dist/cossack-html.d.ts +16 -4
- package/dist/css.d.ts +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -3
- package/dist/server.d.ts +4 -0
- package/dist/server.js +11 -11
- package/package.json +5 -2
- package/dist/cossack-html-D6DeVgtW.js +0 -993
package/dist/cossack-html.d.ts
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { CossackElement } from './cossack-element';
|
|
2
|
-
export
|
|
2
|
+
export type TemplateResultType = 1 | 2;
|
|
3
|
+
export declare class TemplateResult<T extends TemplateResultType = TemplateResultType> {
|
|
3
4
|
readonly strings: TemplateStringsArray;
|
|
4
5
|
readonly values: unknown[];
|
|
5
6
|
readonly _cossack_template_result = true;
|
|
6
|
-
|
|
7
|
+
readonly '_$litType$': T;
|
|
8
|
+
constructor(strings: TemplateStringsArray, values: unknown[], litType?: T);
|
|
9
|
+
/** Component that created this template. Used for Light DOM style ownership. */
|
|
10
|
+
__cossackOwner?: CossackElement;
|
|
11
|
+
/** Scope applied only to elements statically owned by this template. */
|
|
12
|
+
__cossackScope?: string;
|
|
7
13
|
}
|
|
8
|
-
export
|
|
9
|
-
export declare const
|
|
14
|
+
export type SVGTemplateResult = TemplateResult<2>;
|
|
15
|
+
export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult<1>;
|
|
16
|
+
export declare const svg: (strings: TemplateStringsArray, ...values: unknown[]) => SVGTemplateResult;
|
|
17
|
+
/** Lit-compatible sentinel that removes the value in its binding context. */
|
|
18
|
+
export declare const nothing: unique symbol;
|
|
19
|
+
export type ValueSanitizer = (value: unknown) => unknown;
|
|
20
|
+
export type SanitizerFactory = (node: Node, name: string, type: 'property' | 'attribute') => ValueSanitizer;
|
|
21
|
+
export declare const component: <T extends CossackElement>(clazz: new () => T, props?: T['props'] & Record<string, unknown>, children?: unknown) => TemplateResult<1>;
|
|
10
22
|
export declare const isTemplateResult: (value: unknown) => value is TemplateResult;
|
|
11
23
|
export declare class UnsafeHTMLResult {
|
|
12
24
|
readonly value: string;
|
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** A safely constructed block of component CSS. */
|
|
2
|
+
export declare class CSSResult {
|
|
3
|
+
readonly cssText: string;
|
|
4
|
+
/** @internal Use css`` or unsafeCSS() instead. */
|
|
5
|
+
constructor(cssText: string, token: symbol);
|
|
6
|
+
toString(): string;
|
|
7
|
+
}
|
|
8
|
+
export type CSSResultGroup = CSSResult | readonly CSSResultGroup[];
|
|
9
|
+
/**
|
|
10
|
+
* Construct component CSS. Interpolations are intentionally restricted to
|
|
11
|
+
* numbers and other CSSResult values; use unsafeCSS() for reviewed raw text.
|
|
12
|
+
*/
|
|
13
|
+
export declare const css: (strings: TemplateStringsArray, ...values: unknown[]) => CSSResult;
|
|
14
|
+
/** Mark a reviewed raw value as trusted CSS for interpolation into css``. */
|
|
15
|
+
export declare const unsafeCSS: (value: unknown) => CSSResult;
|
|
16
|
+
export interface FinalizedStyles {
|
|
17
|
+
readonly cssText: string;
|
|
18
|
+
readonly scopeId: string;
|
|
19
|
+
}
|
|
20
|
+
/** @internal Finalize and cache a component class's Light DOM styles. */
|
|
21
|
+
export declare const getFinalizedStyles: (componentClass: Function & {
|
|
22
|
+
styles?: CSSResultGroup;
|
|
23
|
+
}) => FinalizedStyles | null;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { A as e, B as t, C as n, D as r, E as i, F as a,
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, K as l, L as u, M as d, N as f, O as p, P as m, R as h, S as g, T as _, U as v, V as y, W as b, _ as x, a as S, b as C, c as w, d as T, f as E, g as D, h as O, i as k, j as A, k as j, l as M, m as N, n as P, o as F, p as I, r as L, s as R, t as z, u as B, v as V, w as H, x as U, y as W, z as G } from "./cossack-html-CnATUTdE.js";
|
|
2
2
|
//#region src/context.ts
|
|
3
|
-
function
|
|
3
|
+
function K(e) {
|
|
4
4
|
return {
|
|
5
5
|
id: Math.random().toString(36).slice(2),
|
|
6
6
|
defaultValue: e
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
9
|
//#endregion
|
|
10
|
-
export {
|
|
10
|
+
export { N as BindResult, v as CSSResult, O as CacheResult, G as CossackElement, D as GuardResult, x as IfDefinedResult, V as KeyResult, W as LiveResult, C as PreventDefaultResult, U as RepeatResult, z as TemplateResult, P as UnsafeHTMLResult, g as bind, n as cache, H as choose, _ as classMap, L as component, K as createContext, b as css, k as escapeHtml, i as guard, S as html, F as hydrate, r as ifDefined, t as instanceStack, l as isComponentResult, R as isTemplateResult, w as isUnsafeHTML, p as join, j as key, e as live, A as map, M as nothing, y as popCurrentInstance, d as preventDefault, s as pushCurrentInstance, f as range, B as render, T as renderToString, m as repeat, a as resolveField, c as setField, u as styleMap, E as svg, o as unsafeCSS, I as unsafeHTML, h as when };
|
package/dist/server.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
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';
|
|
2
6
|
export { minifyHtml } from './minify-html';
|
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { G as e, U as t, W as n, a as r, d as i, f as a, i as o, l as s, t as c } from "./cossack-html-CnATUTdE.js";
|
|
2
2
|
//#region src/minify-html.ts
|
|
3
|
-
var
|
|
3
|
+
var l = /<(script|style|pre|textarea)\b[^>]*>[\s\S]*?<\/\1>/gi, u = RegExp(`<(${[.../* @__PURE__ */ new Set([
|
|
4
4
|
"area",
|
|
5
5
|
"base",
|
|
6
6
|
"br",
|
|
@@ -15,23 +15,23 @@ var n = /<(script|style|pre|textarea)\b[^>]*>[\s\S]*?<\/\1>/gi, r = RegExp(`<(${
|
|
|
15
15
|
"source",
|
|
16
16
|
"track",
|
|
17
17
|
"wbr"
|
|
18
|
-
])].join("|")})(\\s[^>]*)?\\/\\s*>`, "gi"),
|
|
19
|
-
function
|
|
18
|
+
])].join("|")})(\\s[^>]*)?\\/\\s*>`, "gi"), d = /\s+type\s*=\s*["']text\/(javascript|css)["']/gi, f = /(\w[\w-]*)\s*=\s*["']([a-zA-Z0-9_.-]+)["'](?=\s|\/?>)/g;
|
|
19
|
+
function p(e) {
|
|
20
20
|
let t = [];
|
|
21
21
|
return {
|
|
22
|
-
html: e.replace(
|
|
23
|
-
let n = e.replace(
|
|
22
|
+
html: e.replace(l, (e) => {
|
|
23
|
+
let n = e.replace(d, "");
|
|
24
24
|
return t.push(n), `\x00PRESERVE_${t.length - 1}\x00`;
|
|
25
25
|
}),
|
|
26
26
|
blocks: t
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function m(e, t) {
|
|
30
30
|
return e.replace(/\x00PRESERVE_(\d+)\x00/g, (e, n) => t[parseInt(n, 10)]);
|
|
31
31
|
}
|
|
32
|
-
function
|
|
33
|
-
let { html: t, blocks: n } =
|
|
34
|
-
return
|
|
32
|
+
function h(e) {
|
|
33
|
+
let { html: t, blocks: n } = p(e), r = t.replace(/<!--(?!\[if\s|\/?CRP|CSA-[SE])[\s\S]*?-->/g, "");
|
|
34
|
+
return r = r.replace(d, ""), r = r.replace(/\s+/g, " "), r = r.replace(/>\s+</g, "><"), r = r.replace(f, (e, t, n) => `${t}=${n}`), r = r.replace(u, (e, t, n) => `<${t}${n ? n.trimEnd() : ""}>`), r = m(r, n), r = r.replace(/>\s+</g, "><"), r = r.trim(), r;
|
|
35
35
|
}
|
|
36
36
|
//#endregion
|
|
37
|
-
export {
|
|
37
|
+
export { t as CSSResult, c as TemplateResult, n as css, o as escapeHtml, r as html, h as minifyHtml, s as nothing, i as renderToString, a as svg, e as unsafeCSS };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cossackframework/renderer",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "The rendering engine for Cossack Framework. Lit inspired, light dom, ssr",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -28,6 +28,9 @@
|
|
|
28
28
|
"publishConfig": {
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"css-tree": "^3.2.1"
|
|
33
|
+
},
|
|
31
34
|
"devDependencies": {
|
|
32
35
|
"oxlint": "^1.41.0",
|
|
33
36
|
"typescript": "^7.0.2",
|