@takumi-rs/helpers 1.5.1 → 1.7.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/emoji.cjs +1 -1
- package/dist/emoji.d.cts +1 -1
- package/dist/emoji.d.mts +1 -1
- package/dist/emoji.mjs +1 -1
- package/dist/{helpers-cmaAH67r.cjs → helpers-AzWOnvQd.cjs} +1 -1
- package/dist/html.cjs +1 -1
- package/dist/html.d.cts +1 -1
- package/dist/html.d.mts +1 -1
- package/dist/html.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +60 -29
- package/dist/index.d.mts +60 -29
- package/dist/index.mjs +1 -1
- package/dist/jsx.cjs +1 -1
- package/dist/jsx.d.cts +1 -1
- package/dist/jsx.d.mts +1 -1
- package/dist/jsx.mjs +1 -1
- package/dist/{markup-CGcDG4q7.cjs → markup-DuWo8Fkl.cjs} +2 -2
- package/dist/{markup-CerWPaC_.mjs → markup-R4NoHkwK.mjs} +1 -1
- package/dist/{types-BMJCiuSY.d.cts → types-DXcFjeZx.d.cts} +12 -1
- package/dist/{types-CkIMwyWS.d.mts → types-DXcFjeZx.d.mts} +12 -1
- package/package.json +1 -1
- /package/dist/{helpers-6Yvy3K-3.mjs → helpers-CqeNg4sp.mjs} +0 -0
package/dist/emoji.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-AzWOnvQd.cjs"),t=/\uFE0F/g,n=/\p{Extended_Pictographic}/u,r=/^(?:\p{Regional_Indicator}){2}$/u,i=/^[#*0-9]\uFE0F?\u20E3$/u;function a(e){let n=e.indexOf(``)<0?e.replace(t,``):e,r=``;for(let e=0,t=0;e<n.length;e++){let i=n.charCodeAt(e);if(t){let e=(65536+(t-55296<<10)+(i-56320)).toString(16);r+=(r?`-`:``)+e,t=0}else 55296<=i&&i<=56319?t=i:r+=(r?`-`:``)+i.toString(16)}return r}const o={twemoji:e=>`https://cdn.jsdelivr.net/gh/jdecked/twemoji@17.0.2/assets/svg/${e.toLowerCase()}.svg`,openmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/`,blobmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/`,noto:e=>`https://cdn.jsdelivr.net/gh/googlefonts/noto-emoji@v2.051/svg/emoji_u${e.toLowerCase().replaceAll(`-`,`_`)}.svg`,fluent:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_color.svg`,fluentFlat:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_flat.svg`};function s(e,t){let n=a(e),r=o[t];return typeof r==`function`?r(n):`${r}${n.toUpperCase()}.svg`}let c;function l(){return c===void 0&&(c=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(`en`,{granularity:`grapheme`}):null),c}function u(e){let t=l();return t?Array.from(t.segment(e)):Array.from(e).map(e=>({segment:e}))}function d(e){return n.test(e)||r.test(e)||i.test(e)}function f(t,n){let r=[],i=``,a=u(t.text);for(let{segment:t}of a)d(t)?(i&&=(r.push(e.l({text:i})),``),r.push(e.i({src:s(t,n),style:{display:`inline-block`,width:`1em`,height:`1em`,margin:`0 0.05em 0 0.1em`,verticalAlign:`-0.1em`}}))):i+=t;return i&&r.push(e.l({text:i})),r}function p(t,n){if(t.type===`text`){if(u(t.text).some(({segment:e})=>d(e))){let{type:r,...i}=t;return e.t({...i,children:f(t,n)})}}else if(t.type===`container`&&t.children)return{...t,children:t.children.map(e=>e&&p(e,n))};return t}exports.extractEmojis=p;
|
package/dist/emoji.d.cts
CHANGED
package/dist/emoji.d.mts
CHANGED
package/dist/emoji.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,l as t,t as n}from"./helpers-
|
|
1
|
+
import{i as e,l as t,t as n}from"./helpers-CqeNg4sp.mjs";const r=/\uFE0F/g,i=/\p{Extended_Pictographic}/u,a=/^(?:\p{Regional_Indicator}){2}$/u,o=/^[#*0-9]\uFE0F?\u20E3$/u;function s(e){let t=e.indexOf(``)<0?e.replace(r,``):e,n=``;for(let e=0,r=0;e<t.length;e++){let i=t.charCodeAt(e);if(r){let e=(65536+(r-55296<<10)+(i-56320)).toString(16);n+=(n?`-`:``)+e,r=0}else 55296<=i&&i<=56319?r=i:n+=(n?`-`:``)+i.toString(16)}return n}const c={twemoji:e=>`https://cdn.jsdelivr.net/gh/jdecked/twemoji@17.0.2/assets/svg/${e.toLowerCase()}.svg`,openmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/openmoji@2.0.0/svg/`,blobmoji:`https://cdn.jsdelivr.net/npm/@svgmoji/blob@2.0.0/svg/`,noto:e=>`https://cdn.jsdelivr.net/gh/googlefonts/noto-emoji@v2.051/svg/emoji_u${e.toLowerCase().replaceAll(`-`,`_`)}.svg`,fluent:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_color.svg`,fluentFlat:e=>`https://cdn.jsdelivr.net/gh/shuding/fluentui-emoji-unicode/assets/${e.toLowerCase()}_flat.svg`};function l(e,t){let n=s(e),r=c[t];return typeof r==`function`?r(n):`${r}${n.toUpperCase()}.svg`}let u;function d(){return u===void 0&&(u=typeof Intl<`u`&&typeof Intl.Segmenter==`function`?new Intl.Segmenter(`en`,{granularity:`grapheme`}):null),u}function f(e){let t=d();return t?Array.from(t.segment(e)):Array.from(e).map(e=>({segment:e}))}function p(e){return i.test(e)||a.test(e)||o.test(e)}function m(n,r){let i=[],a=``,o=f(n.text);for(let{segment:n}of o)p(n)?(a&&=(i.push(t({text:a})),``),i.push(e({src:l(n,r),style:{display:`inline-block`,width:`1em`,height:`1em`,margin:`0 0.05em 0 0.1em`,verticalAlign:`-0.1em`}}))):a+=n;return a&&i.push(t({text:a})),i}function h(e,t){if(e.type===`text`){if(f(e.text).some(({segment:e})=>p(e))){let{type:r,...i}=e;return n({...i,children:m(e,t)})}}else if(e.type===`container`&&e.children)return{...e,children:e.children.map(e=>e&&h(e,t))};return e}export{h as extractEmojis};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function t(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function n(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id),t.dir!==void 0&&(e.dir=t.dir),t.attributes!==void 0&&(e.attributes=t.attributes)}function r(r){let i={type:`container`,children:r.children};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function i(r,i){if(typeof r==`string`){let t={type:`text`,text:r};return e(t,i),t}let a={type:`text`,text:r.text};return r.tw&&(a.tw=r.tw),n(a,r),t(a,r.preset),e(a,i??r.style),a}function a(r){let i={type:`image`,src:r.src,width:r.width,height:r.height};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function o(e){return e}function s(e){return`${e}%`}function c(e){return`${e}vw`}function l(e){return`${e}vh`}function u(e){return`${e}em`}function d(e){return`${e}rem`}function f(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}Object.defineProperty(exports
|
|
1
|
+
function e(e,t){t&&Object.keys(t).length>0&&(e.style=t)}function t(e,t){t&&Object.keys(t).length>0&&(e.preset=t)}function n(e,t){t.tagName!==void 0&&(e.tagName=t.tagName),t.className!==void 0&&(e.className=t.className),t.id!==void 0&&(e.id=t.id),t.dir!==void 0&&(e.dir=t.dir),t.attributes!==void 0&&(e.attributes=t.attributes)}function r(r){let i={type:`container`,children:r.children};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function i(r,i){if(typeof r==`string`){let t={type:`text`,text:r};return e(t,i),t}let a={type:`text`,text:r.text};return r.tw&&(a.tw=r.tw),n(a,r),t(a,r.preset),e(a,i??r.style),a}function a(r){let i={type:`image`,src:r.src,width:r.width,height:r.height};return r.tw&&(i.tw=r.tw),n(i,r),t(i,r.preset),e(i,r.style),i}function o(e){return e}function s(e){return`${e}%`}function c(e){return`${e}vw`}function l(e){return`${e}vh`}function u(e){return`${e}em`}function d(e){return`${e}rem`}function f(e){return`${e}fr`}function p(e,t,n,r=1){return`rgb(${e} ${t} ${n} / ${r})`}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return l}});
|
package/dist/html.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-AzWOnvQd.cjs"),t=require("./markup-DuWo8Fkl.cjs");function n(n){let{nodes:r,stylesheets:i}=t.t(n);return r.length===0?{node:e.t({}),stylesheets:i}:r.length===1&&r[0]?{node:r[0],stylesheets:i}:{node:e.t({style:{width:e.a(100),height:e.a(100)},children:r}),stylesheets:i}}exports.fromHtml=n;
|
package/dist/html.d.cts
CHANGED
package/dist/html.d.mts
CHANGED
package/dist/html.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,t}from"./helpers-
|
|
1
|
+
import{a as e,t}from"./helpers-CqeNg4sp.mjs";import{t as n}from"./markup-R4NoHkwK.mjs";function r(r){let{nodes:i,stylesheets:a}=n(r);return i.length===0?{node:t({}),stylesheets:a}:i.length===1&&i[0]?{node:i[0],stylesheets:a}:{node:t({style:{width:e(100),height:e(100)},children:i}),stylesheets:a}}export{r as fromHtml};
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-AzWOnvQd.cjs"),t=/url\(\s*(['"]?)(.*?)\1\s*\)/g;function n(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function r(e,i){if(typeof e==`string`)for(let r of e.matchAll(t)){let e=r[2]?.trim();e&&n(e)&&i.add(e)}else if(Array.isArray(e))for(let t of e)r(t,i)}function i(e){let t=new Set,i=e=>{let a=e=>{e&&(r(e.backgroundImage,t),r(e.maskImage,t))};if(a(e.style),a(e.preset),r(e.tw,t),e.type===`image`){typeof e.src==`string`&&n(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])i(t)};return i(e),[...t]}async function a(e,t={}){let n=t.fetch??globalThis.fetch,r=t.timeout===void 0?t.init?.signal:AbortSignal.timeout(t.timeout),i=await n(e,{...t.init,signal:r});if(!i.ok)throw Error(`HTTP ${i.status} ${i.statusText} fetching ${e}`);return i}async function o(e,t){let n=t?.throwOnError??!0,r=t?.timeout??5e3,i=[...new Set(e)].map(async e=>{if(t?.cache?.has(e)){let n=t.cache.get(e);if(n)return{src:e,data:n}}let n=await a(e,{fetch:t?.fetch,timeout:r}).then(e=>e.arrayBuffer());return t?.cache?.set(e,n),{src:e,data:n}});return n?Promise.all(i):(await Promise.allSettled(i)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}function s(e,{weight:t=400,style:n=`normal`,display:r,text:i}){let a=(Array.isArray(t)?[...t].sort((e,t)=>e-t):[t]).map(String),o=Array.isArray(n)?n:[n],s;s=o.includes(`italic`)?`ital,wght@${(o.includes(`normal`)?[0,1]:[1]).flatMap(e=>a.map(t=>`${e},${t}`)).sort().join(`;`)}`:`wght@${a.join(`;`)}`;let c=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:${s}`;return r&&(c+=`&display=${r}`),i&&(c+=`&text=${encodeURIComponent(i)}`),c}function c(e,t){return a(e,{...t,init:{headers:{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36`}}}).then(e=>e.text())}const l=/@font-face\s*\{([^}]*)\}/g;function u(e){let t=[],n=new Set;for(let r of e.matchAll(l)){let e=r[1];if(!e)continue;let i=e.match(/src:\s*url\(([^)]+)\)/)?.[1]?.replace(/['"]/g,``).trim();if(!i||n.has(i))continue;n.add(i);let a=e.match(/font-weight:\s*(\d+)(?:\s+(\d+))?/);t.push({url:i,weight:a&&!a[2]?Number(a[1]):void 0,style:e.match(/font-style:\s*([a-z]+)/i)?.[1]})}return t}async function d(e,t={}){return u(await c(s(e,t),t)).map(n=>({name:e,key:n.url,weight:n.weight,style:n.style,data:()=>a(n.url,t).then(e=>e.arrayBuffer())}))}exports.container=e.t,exports.em=e.n,exports.extractResourceUrls=i,exports.fetchOk=a,exports.fetchResources=o,exports.fr=e.r,exports.googleFont=d,exports.image=e.i,exports.percentage=e.a,exports.rem=e.o,exports.rgba=e.s,exports.style=e.c,exports.text=e.l,exports.vh=e.u,exports.vw=e.d;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
|
-
import { a as NodeMetadata, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as
|
|
1
|
+
import { a as NodeMetadata, c as TextNode, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextFit, t as ContainerNode } from "./types-DXcFjeZx.cjs";
|
|
2
2
|
import { CSSProperties } from "react";
|
|
3
3
|
|
|
4
|
-
//#region src/helpers.d.ts
|
|
5
|
-
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
6
|
-
declare function text(text: string, style?: CSSProperties): TextNode;
|
|
7
|
-
declare function text(props: Omit<TextNode, "type">): TextNode;
|
|
8
|
-
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
9
|
-
declare function style(style: CSSProperties): CSSProperties;
|
|
10
|
-
declare function percentage(percentage: number): `${number}%`;
|
|
11
|
-
declare function vw(vw: number): `${number}vw`;
|
|
12
|
-
declare function vh(vh: number): `${number}vh`;
|
|
13
|
-
declare function em(em: number): `${number}em`;
|
|
14
|
-
declare function rem(rem: number): `${number}rem`;
|
|
15
|
-
declare function fr(fr: number): `${number}fr`;
|
|
16
|
-
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
17
|
-
//#endregion
|
|
18
4
|
//#region src/utils.d.ts
|
|
19
5
|
declare function extractResourceUrls(node: Node): string[];
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @default 5000
|
|
24
|
-
*/
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
type FetchOptions = {
|
|
8
|
+
/** Custom fetch implementation. @default globalThis.fetch */fetch?: FetchLike; /** Abort the request after this many milliseconds. */
|
|
25
9
|
timeout?: number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
};
|
|
11
|
+
/** Fetches a URL, applying a timeout signal and throwing on a non-OK status. */
|
|
12
|
+
declare function fetchOk(url: string, options?: FetchOptions & {
|
|
13
|
+
init?: RequestInit;
|
|
14
|
+
}): Promise<Response>;
|
|
15
|
+
type FetchResourcesOptions = FetchOptions & {
|
|
31
16
|
/**
|
|
32
17
|
* Whether to throw on any fetch failure. If false, returns only successful fetches.
|
|
33
18
|
* @default true
|
|
@@ -40,11 +25,10 @@ type FetchResourcesOptions = {
|
|
|
40
25
|
cache?: Pick<Map<string, ArrayBuffer>, "has" | "get" | "set">;
|
|
41
26
|
};
|
|
42
27
|
/**
|
|
43
|
-
* Fetches multiple resources concurrently.
|
|
44
|
-
* Validates HTTP status codes and automatically deduplicates URLs.
|
|
28
|
+
* Fetches multiple resources concurrently, deduplicating URLs.
|
|
45
29
|
*
|
|
46
30
|
* @param urls - URLs to fetch
|
|
47
|
-
* @param options - Fetch options
|
|
31
|
+
* @param options - Fetch options; `timeout` defaults to 5000ms
|
|
48
32
|
* @returns Array of { src: string, data: ArrayBuffer }
|
|
49
33
|
*/
|
|
50
34
|
declare function fetchResources(urls: string[], options?: FetchResourcesOptions): Promise<{
|
|
@@ -52,4 +36,51 @@ declare function fetchResources(urls: string[], options?: FetchResourcesOptions)
|
|
|
52
36
|
data: ArrayBuffer;
|
|
53
37
|
}[]>;
|
|
54
38
|
//#endregion
|
|
55
|
-
|
|
39
|
+
//#region src/fonts.d.ts
|
|
40
|
+
type FontStyle = "normal" | "italic";
|
|
41
|
+
type GoogleFontOptions = FetchOptions & {
|
|
42
|
+
/**
|
|
43
|
+
* `400` for one weight, `[400, 700]` for several, or a range like `"100..900"` to load
|
|
44
|
+
* the variable font. A range leaves the weight unset so CSS `font-weight` controls it.
|
|
45
|
+
* @default 400
|
|
46
|
+
*/
|
|
47
|
+
weight?: number | number[] | `${number}..${number}`; /** `"normal"`, `"italic"`, or both. @default "normal" */
|
|
48
|
+
style?: FontStyle | FontStyle[]; /** Limit the download to the glyphs used in this text. Recommended for OG images. */
|
|
49
|
+
text?: string; /** `font-display` strategy passed through to the CSS request. */
|
|
50
|
+
display?: "auto" | "block" | "swap" | "fallback" | "optional";
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Load a Google Font as descriptors you can pass to a renderer's `fonts`. Fetches the
|
|
54
|
+
* Google Fonts CSS, reads the `woff2` URLs, and returns one loader per file. Each file
|
|
55
|
+
* downloads when the renderer first needs it; the renderer skips files it already loaded.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* fonts: await googleFont("Inter", { weight: [400, 700] })
|
|
59
|
+
* @example
|
|
60
|
+
* fonts: await googleFont("Inter", { weight: "100..900" }) // variable
|
|
61
|
+
* @example
|
|
62
|
+
* fonts: await googleFont("Inter", { weight: 700, style: "italic", text: "Hello" })
|
|
63
|
+
*/
|
|
64
|
+
declare function googleFont(family: string, options?: GoogleFontOptions): Promise<{
|
|
65
|
+
name: string;
|
|
66
|
+
key: string;
|
|
67
|
+
weight: number | undefined;
|
|
68
|
+
style: string | undefined;
|
|
69
|
+
data: () => Promise<ArrayBuffer>;
|
|
70
|
+
}[]>;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/helpers.d.ts
|
|
73
|
+
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
74
|
+
declare function text(text: string, style?: CSSProperties): TextNode;
|
|
75
|
+
declare function text(props: Omit<TextNode, "type">): TextNode;
|
|
76
|
+
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
77
|
+
declare function style(style: CSSProperties): CSSProperties;
|
|
78
|
+
declare function percentage(percentage: number): `${number}%`;
|
|
79
|
+
declare function vw(vw: number): `${number}vw`;
|
|
80
|
+
declare function vh(vh: number): `${number}vh`;
|
|
81
|
+
declare function em(em: number): `${number}em`;
|
|
82
|
+
declare function rem(rem: number): `${number}rem`;
|
|
83
|
+
declare function fr(fr: number): `${number}fr`;
|
|
84
|
+
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ContainerNode, FetchLike, FetchOptions, FetchResourcesOptions, GoogleFontOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextFit, TextNode, container, em, extractResourceUrls, fetchOk, fetchResources, fr, googleFont, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,33 +1,18 @@
|
|
|
1
|
-
import { a as NodeMetadata, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as
|
|
1
|
+
import { a as NodeMetadata, c as TextNode, i as NodeAttributes, n as ImageNode, o as ReactElementLike, r as Node, s as TextFit, t as ContainerNode } from "./types-DXcFjeZx.mjs";
|
|
2
2
|
import { CSSProperties } from "react";
|
|
3
3
|
|
|
4
|
-
//#region src/helpers.d.ts
|
|
5
|
-
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
6
|
-
declare function text(text: string, style?: CSSProperties): TextNode;
|
|
7
|
-
declare function text(props: Omit<TextNode, "type">): TextNode;
|
|
8
|
-
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
9
|
-
declare function style(style: CSSProperties): CSSProperties;
|
|
10
|
-
declare function percentage(percentage: number): `${number}%`;
|
|
11
|
-
declare function vw(vw: number): `${number}vw`;
|
|
12
|
-
declare function vh(vh: number): `${number}vh`;
|
|
13
|
-
declare function em(em: number): `${number}em`;
|
|
14
|
-
declare function rem(rem: number): `${number}rem`;
|
|
15
|
-
declare function fr(fr: number): `${number}fr`;
|
|
16
|
-
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
17
|
-
//#endregion
|
|
18
4
|
//#region src/utils.d.ts
|
|
19
5
|
declare function extractResourceUrls(node: Node): string[];
|
|
20
|
-
type
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* @default 5000
|
|
24
|
-
*/
|
|
6
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
7
|
+
type FetchOptions = {
|
|
8
|
+
/** Custom fetch implementation. @default globalThis.fetch */fetch?: FetchLike; /** Abort the request after this many milliseconds. */
|
|
25
9
|
timeout?: number;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
};
|
|
11
|
+
/** Fetches a URL, applying a timeout signal and throwing on a non-OK status. */
|
|
12
|
+
declare function fetchOk(url: string, options?: FetchOptions & {
|
|
13
|
+
init?: RequestInit;
|
|
14
|
+
}): Promise<Response>;
|
|
15
|
+
type FetchResourcesOptions = FetchOptions & {
|
|
31
16
|
/**
|
|
32
17
|
* Whether to throw on any fetch failure. If false, returns only successful fetches.
|
|
33
18
|
* @default true
|
|
@@ -40,11 +25,10 @@ type FetchResourcesOptions = {
|
|
|
40
25
|
cache?: Pick<Map<string, ArrayBuffer>, "has" | "get" | "set">;
|
|
41
26
|
};
|
|
42
27
|
/**
|
|
43
|
-
* Fetches multiple resources concurrently.
|
|
44
|
-
* Validates HTTP status codes and automatically deduplicates URLs.
|
|
28
|
+
* Fetches multiple resources concurrently, deduplicating URLs.
|
|
45
29
|
*
|
|
46
30
|
* @param urls - URLs to fetch
|
|
47
|
-
* @param options - Fetch options
|
|
31
|
+
* @param options - Fetch options; `timeout` defaults to 5000ms
|
|
48
32
|
* @returns Array of { src: string, data: ArrayBuffer }
|
|
49
33
|
*/
|
|
50
34
|
declare function fetchResources(urls: string[], options?: FetchResourcesOptions): Promise<{
|
|
@@ -52,4 +36,51 @@ declare function fetchResources(urls: string[], options?: FetchResourcesOptions)
|
|
|
52
36
|
data: ArrayBuffer;
|
|
53
37
|
}[]>;
|
|
54
38
|
//#endregion
|
|
55
|
-
|
|
39
|
+
//#region src/fonts.d.ts
|
|
40
|
+
type FontStyle = "normal" | "italic";
|
|
41
|
+
type GoogleFontOptions = FetchOptions & {
|
|
42
|
+
/**
|
|
43
|
+
* `400` for one weight, `[400, 700]` for several, or a range like `"100..900"` to load
|
|
44
|
+
* the variable font. A range leaves the weight unset so CSS `font-weight` controls it.
|
|
45
|
+
* @default 400
|
|
46
|
+
*/
|
|
47
|
+
weight?: number | number[] | `${number}..${number}`; /** `"normal"`, `"italic"`, or both. @default "normal" */
|
|
48
|
+
style?: FontStyle | FontStyle[]; /** Limit the download to the glyphs used in this text. Recommended for OG images. */
|
|
49
|
+
text?: string; /** `font-display` strategy passed through to the CSS request. */
|
|
50
|
+
display?: "auto" | "block" | "swap" | "fallback" | "optional";
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Load a Google Font as descriptors you can pass to a renderer's `fonts`. Fetches the
|
|
54
|
+
* Google Fonts CSS, reads the `woff2` URLs, and returns one loader per file. Each file
|
|
55
|
+
* downloads when the renderer first needs it; the renderer skips files it already loaded.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* fonts: await googleFont("Inter", { weight: [400, 700] })
|
|
59
|
+
* @example
|
|
60
|
+
* fonts: await googleFont("Inter", { weight: "100..900" }) // variable
|
|
61
|
+
* @example
|
|
62
|
+
* fonts: await googleFont("Inter", { weight: 700, style: "italic", text: "Hello" })
|
|
63
|
+
*/
|
|
64
|
+
declare function googleFont(family: string, options?: GoogleFontOptions): Promise<{
|
|
65
|
+
name: string;
|
|
66
|
+
key: string;
|
|
67
|
+
weight: number | undefined;
|
|
68
|
+
style: string | undefined;
|
|
69
|
+
data: () => Promise<ArrayBuffer>;
|
|
70
|
+
}[]>;
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/helpers.d.ts
|
|
73
|
+
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
|
74
|
+
declare function text(text: string, style?: CSSProperties): TextNode;
|
|
75
|
+
declare function text(props: Omit<TextNode, "type">): TextNode;
|
|
76
|
+
declare function image(props: Omit<ImageNode, "type">): ImageNode;
|
|
77
|
+
declare function style(style: CSSProperties): CSSProperties;
|
|
78
|
+
declare function percentage(percentage: number): `${number}%`;
|
|
79
|
+
declare function vw(vw: number): `${number}vw`;
|
|
80
|
+
declare function vh(vh: number): `${number}vh`;
|
|
81
|
+
declare function em(em: number): `${number}em`;
|
|
82
|
+
declare function rem(rem: number): `${number}rem`;
|
|
83
|
+
declare function fr(fr: number): `${number}fr`;
|
|
84
|
+
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ContainerNode, FetchLike, FetchOptions, FetchResourcesOptions, GoogleFontOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextFit, TextNode, container, em, extractResourceUrls, fetchOk, fetchResources, fr, googleFont, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./helpers-
|
|
1
|
+
import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./helpers-CqeNg4sp.mjs";const d=/url\(\s*(['"]?)(.*?)\1\s*\)/g;function f(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function p(e,t){if(typeof e==`string`)for(let n of e.matchAll(d)){let e=n[2]?.trim();e&&f(e)&&t.add(e)}else if(Array.isArray(e))for(let n of e)p(n,t)}function m(e){let t=new Set,n=e=>{let r=e=>{e&&(p(e.backgroundImage,t),p(e.maskImage,t))};if(r(e.style),r(e.preset),p(e.tw,t),e.type===`image`){typeof e.src==`string`&&f(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}async function h(e,t={}){let n=t.fetch??globalThis.fetch,r=t.timeout===void 0?t.init?.signal:AbortSignal.timeout(t.timeout),i=await n(e,{...t.init,signal:r});if(!i.ok)throw Error(`HTTP ${i.status} ${i.statusText} fetching ${e}`);return i}async function g(e,t){let n=t?.throwOnError??!0,r=t?.timeout??5e3,i=[...new Set(e)].map(async e=>{if(t?.cache?.has(e)){let n=t.cache.get(e);if(n)return{src:e,data:n}}let n=await h(e,{fetch:t?.fetch,timeout:r}).then(e=>e.arrayBuffer());return t?.cache?.set(e,n),{src:e,data:n}});return n?Promise.all(i):(await Promise.allSettled(i)).filter(e=>e.status===`fulfilled`).map(e=>e.value)}function _(e,{weight:t=400,style:n=`normal`,display:r,text:i}){let a=(Array.isArray(t)?[...t].sort((e,t)=>e-t):[t]).map(String),o=Array.isArray(n)?n:[n],s;s=o.includes(`italic`)?`ital,wght@${(o.includes(`normal`)?[0,1]:[1]).flatMap(e=>a.map(t=>`${e},${t}`)).sort().join(`;`)}`:`wght@${a.join(`;`)}`;let c=`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:${s}`;return r&&(c+=`&display=${r}`),i&&(c+=`&text=${encodeURIComponent(i)}`),c}function v(e,t){return h(e,{...t,init:{headers:{"User-Agent":`Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36`}}}).then(e=>e.text())}const y=/@font-face\s*\{([^}]*)\}/g;function b(e){let t=[],n=new Set;for(let r of e.matchAll(y)){let e=r[1];if(!e)continue;let i=e.match(/src:\s*url\(([^)]+)\)/)?.[1]?.replace(/['"]/g,``).trim();if(!i||n.has(i))continue;n.add(i);let a=e.match(/font-weight:\s*(\d+)(?:\s+(\d+))?/);t.push({url:i,weight:a&&!a[2]?Number(a[1]):void 0,style:e.match(/font-style:\s*([a-z]+)/i)?.[1]})}return t}async function x(e,t={}){return b(await v(_(e,t),t)).map(n=>({name:e,key:n.url,weight:n.weight,style:n.style,data:()=>h(n.url,t).then(e=>e.arrayBuffer())}))}export{l as container,a as em,m as extractResourceUrls,h as fetchOk,g as fetchResources,s as fr,x as googleFont,r as image,e as percentage,o as rem,c as rgba,t as style,i as text,u as vh,n as vw};
|
package/dist/jsx.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-AzWOnvQd.cjs"),t=require("./markup-DuWo8Fkl.cjs");function n(e){return typeof e==`string`||typeof e==`number`}function r(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function i(e){let n=[];for(let r in e)Object.hasOwn(e,r)&&n.push(`${t.n(r)}:${String(e[r]).trim()}`);return n.join(`;`)}const a=new Set(`stopColor.stopOpacity.strokeWidth.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.fillRule.clipRule.colorInterpolationFilters.floodColor.floodOpacity.accentHeight.alignmentBaseline.arabicForm.baselineShift.capHeight.clipPath.clipPathUnits.colorInterpolation.colorProfile.colorRendering.enableBackground.fillOpacity.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.horizAdvX.horizOriginX.imageRendering.letterSpacing.lightingColor.markerEnd.markerMid.markerStart.overlinePosition.overlineThickness.paintOrder.preserveAspectRatio.pointerEvents.shapeRendering.strokeMiterlimit.strokeOpacity.textAnchor.textDecoration.textRendering.transformOrigin.underlinePosition.underlineThickness.unicodeBidi.unicodeRange.unitsPerEm.vectorEffect.vertAdvY.vertOriginX.vertOriginY.vAlphabetic.vHanging.vIdeographic.vMathematical.wordSpacing.writingMode`.split(`.`));function o(e,n){if(e===`children`||n==null)return;let o;if(o=e===`className`?`class`:a.has(e)?t.n(e):e,typeof n==`boolean`)return`${o}="${String(n)}"`;if(e===`style`&&typeof n==`object`){let e=i(n);if(e)return`style="${r(e)}"`}return`${o}="${r(String(n))}"`}function s(e,t,n){let r=!1;for(let n in e){if(!Object.hasOwn(e,n))continue;let i=o(n,e[n]);i!==void 0&&(t.push(` `,i),n===`xmlns`&&(r=!0))}n&&!r&&t.push(` xmlns="http://www.w3.org/2000/svg"`)}const c=(e,n,r)=>{let i=e.props||{};if(t.r(e.type)){l(e.type(e.props),n,!1);return}if(typeof e.type==`symbol`||typeof e.type!=`string`)return;n.push(`<`,e.type),s(i,n,r&&e.type===`svg`);let a=i.children;n.push(`>`),l(a,n,!1),n.push(`</`,e.type,`>`)};function l(e,r,i){if(!(e==null||e===!1)){if(n(e)){r.push(String(e));return}if(Array.isArray(e)){for(let t of e)l(t,r,!1);return}t.l(e)&&c(e,r,i)}}function u(e){let t=[];return l(e,t,!0),t.join(``)}function d(){return{nodes:[],stylesheets:[]}}const f=[/Invalid hook call\./,/Cannot read properties of null \(reading 'use[A-Z][A-Za-z]+'\)/,/null is not an object \(evaluating 'dispatcher\.use[A-Z][A-Za-z]+'\)/];let p,m;async function h(n,r){let i={defaultStyles:_(r),presets:t.d(r?.defaultStyles),tailwindClassesProperty:r?.tailwindClassesProperty??`tw`},a=await g(n,i).catch(async e=>{if(!y(e))throw e;return await O(n,i)||g(n,i)}),o=a.nodes,s;return s=o.length===0?e.t({}):o.length===1&&o[0]!==void 0?o[0]:e.t({children:o,style:{width:e.a(100),height:e.a(100)}}),{node:s,stylesheets:a.stylesheets}}async function g(n,r){return n==null||n===!1?d():n instanceof Promise?g(await n,r):typeof n==`object`&&Symbol.iterator in n?B(n,r):t.l(n)?await N(n,r):{nodes:[e.l({text:String(n),preset:r.presets?.span})],stylesheets:[]}}function _(e){return e&&`defaultStyles`in e?e.defaultStyles??t.f:t.f}function v(e){return!t.l(e)||typeof e.type!=`object`||e.type===null||!(`$$typeof`in e.type)?!1:e.type.$$typeof===Symbol.for(`react.context`)||e.type.$$typeof===Symbol.for(`react.provider`)}function y(e){return e instanceof Error?f.some(t=>t.test(e.message)):!1}async function b(e){let t=console.error;console.error=(...e)=>{let[n]=e;typeof n==`string`&&f.some(e=>e.test(n))||t(...e)};try{return await e()}finally{console.error=t}}async function x(e,t,n){return b(()=>g(e(t),n))}function S(e,n){if(!(typeof e.type!=`object`||e.type===null)){if(t.o(e.type)&&`render`in e.type){let t=e.type;return x(e=>t.render(e,null),e.props,n)}if(t.c(e.type)&&`type`in e.type){let r=e.type.type;return t.r(r)?x(r,e.props,n):N({...e,type:r},n)}}}function C(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function w(e){return typeof e==`object`&&!!e&&`createElement`in e&&typeof e.createElement==`function`}function T(e){return typeof e==`object`&&!!e&&`renderToStaticMarkup`in e&&typeof e.renderToStaticMarkup==`function`}async function E(){return m??=import(`react`).then(e=>{let t=e.default??e;return w(t)?t:null}).catch(()=>null),m}async function D(){return p??=import(`react-dom/server`).then(e=>{let t=e.default??e;return T(t)?t:null}).catch(()=>null),p}async function O(e,n){let[r,i]=await Promise.all([E(),D()]);return!r||!i?null:t.t(i.renderToStaticMarkup(r.createElement(r.Fragment??void 0,null,e)),{defaultStyles:n.defaultStyles,tailwindClassesProperty:n.tailwindClassesProperty})}function k(e){if(!t.l(e))return;let n=C(e);if(typeof n==`string`)return n;if(typeof n==`number`)return String(n);if(Array.isArray(n)||typeof n==`object`&&n&&Symbol.iterator in n)return M(n);if(t.l(n)&&t.s(n))return k(n)}function A(e){let t=[];for(let n of e){let e=j(n);if(e===void 0)return;t.push(e)}return t.join(``)}function j(e){if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(e==null||typeof e==`boolean`||typeof e==`symbol`)return``;if(typeof e==`object`&&Symbol.iterator in e)return A(e);if(!t.l(e))return;if(t.s(e))return j(C(e));let n=C(e);return n===void 0?``:typeof n==`object`&&n&&Symbol.iterator in n?A(n):j(n)}function M(e){let n=[];for(let r of e){if(t.l(r))return;if(typeof r==`string`){n.push(r);continue}if(typeof r==`number`){n.push(String(r));continue}return}return n.join(``)}async function N(n,r){if(v(n))return await O(n,r)||z(n,r);if(t.r(n.type))return x(n.type,n.props,r);let i=S(n,r);if(i!==void 0)return i;if(t.s(n))return z(n,r);if(t.i(n,`style`)){let e=j(C(n));return{nodes:[],stylesheets:e&&e.length>0?[e]:[]}}if(typeof n.type!=`string`||t.a(n.type))return d();let a=R(n,r);if(t.i(n,`br`))return{nodes:[e.l({text:`
|
|
2
2
|
`,preset:r.presets?.span,...a})],stylesheets:[]};if(t.i(n,`img`))return{nodes:[P(n,r)],stylesheets:[]};if(t.i(n,`svg`))return{nodes:[F(n,r)],stylesheets:[]};let o=k(n);if(o!==void 0)return{nodes:[e.l({text:o,...a})],stylesheets:[]};let s=await z(n,r);return{nodes:[e.t({children:s.nodes,...a})],stylesheets:s.stylesheets}}function P(t,n){if(!t.props.src)throw Error(`Image element must have a 'src' prop.`);let r=R(t,n),i=t.props.width===void 0?void 0:Number(t.props.width),a=t.props.height===void 0?void 0:Number(t.props.height);return e.i({src:t.props.src,width:i,height:a,...r})}function F(t,n){let r=R(t,n);return e.i({src:u(t),width:t.props.width===void 0?void 0:Number(t.props.width),height:t.props.height===void 0?void 0:Number(t.props.height),...r})}function I(e,t){let n=t.presets,r=n&&typeof e.type==`string`&&e.type in n?n[e.type]:void 0,i=typeof e.props==`object`&&e.props!==null&&`style`in e.props&&typeof e.props.style==`object`&&e.props.style!==null?e.props.style:void 0;if(!i)return{preset:r};for(let e in i)if(Object.hasOwn(i,e))return{preset:r,style:i};return{preset:r}}function L(e,t){let n=t.tailwindClassesProperty;if(typeof e.props!=`object`||e.props===null||!(n in e.props))return;let r=e.props[n];if(typeof r==`string`)return r}function R(e,n){let r=e.props,{preset:i,style:a}=I(e,n),o=L(e,n),s=t.u(r,n.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:r.className??r.class,id:r.id,dir:r.dir,attributes:s,tw:o,style:a,preset:i}}function z(e,t){let n=C(e);return n===void 0?Promise.resolve(d()):g(n,t)}async function B(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=g(a,t).then(t=>{n[e]=t}).finally(()=>r.delete(o));r.add(o),r.size>=8&&await Promise.race(r)}await Promise.all(r);let a=[],o=[];for(let e of n)e&&(a.push(...e.nodes),o.push(...e.stylesheets));return{nodes:a,stylesheets:o}}exports.defaultStylePresets=t.f,exports.fromJsx=h;
|
package/dist/jsx.d.cts
CHANGED
package/dist/jsx.d.mts
CHANGED
package/dist/jsx.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e,i as t,l as n,t as r}from"./helpers-
|
|
1
|
+
import{a as e,i as t,l as n,t as r}from"./helpers-CqeNg4sp.mjs";import{a as i,c as a,d as o,f as s,i as c,l,n as u,o as d,r as f,s as p,t as m,u as h}from"./markup-R4NoHkwK.mjs";function g(e){return typeof e==`string`||typeof e==`number`}function _(e){return e.replace(/&/g,`&`).replace(/"/g,`"`).replace(/</g,`<`).replace(/>/g,`>`)}function v(e){let t=[];for(let n in e)Object.hasOwn(e,n)&&t.push(`${u(n)}:${String(e[n]).trim()}`);return t.join(`;`)}const y=new Set(`stopColor.stopOpacity.strokeWidth.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.fillRule.clipRule.colorInterpolationFilters.floodColor.floodOpacity.accentHeight.alignmentBaseline.arabicForm.baselineShift.capHeight.clipPath.clipPathUnits.colorInterpolation.colorProfile.colorRendering.enableBackground.fillOpacity.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.horizAdvX.horizOriginX.imageRendering.letterSpacing.lightingColor.markerEnd.markerMid.markerStart.overlinePosition.overlineThickness.paintOrder.preserveAspectRatio.pointerEvents.shapeRendering.strokeMiterlimit.strokeOpacity.textAnchor.textDecoration.textRendering.transformOrigin.underlinePosition.underlineThickness.unicodeBidi.unicodeRange.unitsPerEm.vectorEffect.vertAdvY.vertOriginX.vertOriginY.vAlphabetic.vHanging.vIdeographic.vMathematical.wordSpacing.writingMode`.split(`.`));function b(e,t){if(e===`children`||t==null)return;let n;if(n=e===`className`?`class`:y.has(e)?u(e):e,typeof t==`boolean`)return`${n}="${String(t)}"`;if(e===`style`&&typeof t==`object`){let e=v(t);if(e)return`style="${_(e)}"`}return`${n}="${_(String(t))}"`}function x(e,t,n){let r=!1;for(let n in e){if(!Object.hasOwn(e,n))continue;let i=b(n,e[n]);i!==void 0&&(t.push(` `,i),n===`xmlns`&&(r=!0))}n&&!r&&t.push(` xmlns="http://www.w3.org/2000/svg"`)}const S=(e,t,n)=>{let r=e.props||{};if(f(e.type)){C(e.type(e.props),t,!1);return}if(typeof e.type==`symbol`||typeof e.type!=`string`)return;t.push(`<`,e.type),x(r,t,n&&e.type===`svg`);let i=r.children;t.push(`>`),C(i,t,!1),t.push(`</`,e.type,`>`)};function C(e,t,n){if(!(e==null||e===!1)){if(g(e)){t.push(String(e));return}if(Array.isArray(e)){for(let n of e)C(n,t,!1);return}l(e)&&S(e,t,n)}}function w(e){let t=[];return C(e,t,!0),t.join(``)}function T(){return{nodes:[],stylesheets:[]}}const E=[/Invalid hook call\./,/Cannot read properties of null \(reading 'use[A-Z][A-Za-z]+'\)/,/null is not an object \(evaluating 'dispatcher\.use[A-Z][A-Za-z]+'\)/];let D,O;async function k(t,n){let i={defaultStyles:j(n),presets:o(n?.defaultStyles),tailwindClassesProperty:n?.tailwindClassesProperty??`tw`},a=await A(t,i).catch(async e=>{if(!N(e))throw e;return await H(t,i)||A(t,i)}),s=a.nodes,c;return c=s.length===0?r({}):s.length===1&&s[0]!==void 0?s[0]:r({children:s,style:{width:e(100),height:e(100)}}),{node:c,stylesheets:a.stylesheets}}async function A(e,t){return e==null||e===!1?T():e instanceof Promise?A(await e,t):typeof e==`object`&&Symbol.iterator in e?ee(e,t):l(e)?await q(e,t):{nodes:[n({text:String(e),preset:t.presets?.span})],stylesheets:[]}}function j(e){return e&&`defaultStyles`in e?e.defaultStyles??s:s}function M(e){return!l(e)||typeof e.type!=`object`||e.type===null||!(`$$typeof`in e.type)?!1:e.type.$$typeof===Symbol.for(`react.context`)||e.type.$$typeof===Symbol.for(`react.provider`)}function N(e){return e instanceof Error?E.some(t=>t.test(e.message)):!1}async function P(e){let t=console.error;console.error=(...e)=>{let[n]=e;typeof n==`string`&&E.some(e=>e.test(n))||t(...e)};try{return await e()}finally{console.error=t}}async function F(e,t,n){return P(()=>A(e(t),n))}function I(e,t){if(!(typeof e.type!=`object`||e.type===null)){if(d(e.type)&&`render`in e.type){let n=e.type;return F(e=>n.render(e,null),e.props,t)}if(a(e.type)&&`type`in e.type){let n=e.type.type;return f(n)?F(n,e.props,t):q({...e,type:n},t)}}}function L(e){if(typeof e.props==`object`&&e.props!==null&&`children`in e.props)return e.props.children}function R(e){return typeof e==`object`&&!!e&&`createElement`in e&&typeof e.createElement==`function`}function z(e){return typeof e==`object`&&!!e&&`renderToStaticMarkup`in e&&typeof e.renderToStaticMarkup==`function`}async function B(){return O??=import(`react`).then(e=>{let t=e.default??e;return R(t)?t:null}).catch(()=>null),O}async function V(){return D??=import(`react-dom/server`).then(e=>{let t=e.default??e;return z(t)?t:null}).catch(()=>null),D}async function H(e,t){let[n,r]=await Promise.all([B(),V()]);return!n||!r?null:m(r.renderToStaticMarkup(n.createElement(n.Fragment??void 0,null,e)),{defaultStyles:t.defaultStyles,tailwindClassesProperty:t.tailwindClassesProperty})}function U(e){if(!l(e))return;let t=L(e);if(typeof t==`string`)return t;if(typeof t==`number`)return String(t);if(Array.isArray(t)||typeof t==`object`&&t&&Symbol.iterator in t)return K(t);if(l(t)&&p(t))return U(t)}function W(e){let t=[];for(let n of e){let e=G(n);if(e===void 0)return;t.push(e)}return t.join(``)}function G(e){if(typeof e==`string`)return e;if(typeof e==`number`)return String(e);if(e==null||typeof e==`boolean`||typeof e==`symbol`)return``;if(typeof e==`object`&&Symbol.iterator in e)return W(e);if(!l(e))return;if(p(e))return G(L(e));let t=L(e);return t===void 0?``:typeof t==`object`&&t&&Symbol.iterator in t?W(t):G(t)}function K(e){let t=[];for(let n of e){if(l(n))return;if(typeof n==`string`){t.push(n);continue}if(typeof n==`number`){t.push(String(n));continue}return}return t.join(``)}async function q(e,t){if(M(e))return await H(e,t)||$(e,t);if(f(e.type))return F(e.type,e.props,t);let a=I(e,t);if(a!==void 0)return a;if(p(e))return $(e,t);if(c(e,`style`)){let t=G(L(e));return{nodes:[],stylesheets:t&&t.length>0?[t]:[]}}if(typeof e.type!=`string`||i(e.type))return T();let o=Q(e,t);if(c(e,`br`))return{nodes:[n({text:`
|
|
2
2
|
`,preset:t.presets?.span,...o})],stylesheets:[]};if(c(e,`img`))return{nodes:[J(e,t)],stylesheets:[]};if(c(e,`svg`))return{nodes:[Y(e,t)],stylesheets:[]};let s=U(e);if(s!==void 0)return{nodes:[n({text:s,...o})],stylesheets:[]};let l=await $(e,t);return{nodes:[r({children:l.nodes,...o})],stylesheets:l.stylesheets}}function J(e,n){if(!e.props.src)throw Error(`Image element must have a 'src' prop.`);let r=Q(e,n),i=e.props.width===void 0?void 0:Number(e.props.width),a=e.props.height===void 0?void 0:Number(e.props.height);return t({src:e.props.src,width:i,height:a,...r})}function Y(e,n){let r=Q(e,n);return t({src:w(e),width:e.props.width===void 0?void 0:Number(e.props.width),height:e.props.height===void 0?void 0:Number(e.props.height),...r})}function X(e,t){let n=t.presets,r=n&&typeof e.type==`string`&&e.type in n?n[e.type]:void 0,i=typeof e.props==`object`&&e.props!==null&&`style`in e.props&&typeof e.props.style==`object`&&e.props.style!==null?e.props.style:void 0;if(!i)return{preset:r};for(let e in i)if(Object.hasOwn(i,e))return{preset:r,style:i};return{preset:r}}function Z(e,t){let n=t.tailwindClassesProperty;if(typeof e.props!=`object`||e.props===null||!(n in e.props))return;let r=e.props[n];if(typeof r==`string`)return r}function Q(e,t){let n=e.props,{preset:r,style:i}=X(e,t),a=Z(e,t),o=h(n,t.tailwindClassesProperty);return{tagName:typeof e.type==`string`?e.type:void 0,className:n.className??n.class,id:n.id,dir:n.dir,attributes:o,tw:a,style:i,preset:r}}function $(e,t){let n=L(e);return n===void 0?Promise.resolve(T()):A(n,t)}async function ee(e,t){let n=[],r=new Set,i=0;for(let a of e){let e=i;i+=1;let o=A(a,t).then(t=>{n[e]=t}).finally(()=>r.delete(o));r.add(o),r.size>=8&&await Promise.race(r)}await Promise.all(r);let a=[],o=[];for(let e of n)e&&(a.push(...e.nodes),o.push(...e.stylesheets));return{nodes:a,stylesheets:o}}export{s as defaultStylePresets,k as fromJsx};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require(
|
|
2
|
-
`,preset:n?.span,...s}));return}if(o.name===`img`){let t=o.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);i.push(e.i({src:t,width:H(o.attributes?.width),height:H(o.attributes?.height),...s}));return}if(S(o.name))return;if(o.name===`svg`){i.push(e.i({src:b(o),width:H(o.attributes?.width),height:H(o.attributes?.height),...s}));return}let c=!0,l=``;for(let e of o.children)if(e.type!==3){if(e.type!==2){c=!1;break}l+=e.value??``}if(c&&l){i.push(e.l({text:l,...s}));return}let u=[];for(let e of o.children)P(e,n,r,u,a);i.push(e.t({children:u,...s}))}function F(e,t,n){let i=e.attributes?I(e.attributes):{},a=typeof i.style==`string`?B(i.style):void 0,o=r(i,n),s=typeof i[n]==`string`?i[n]:void 0,c=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:i.class,id:i.id,dir:i.dir,attributes:o,tw:s,style:a,preset:c}}function I(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=L(r))}return t}function L(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?R(Number(t))??e:n?R(Number.parseInt(n,16))??e:z[r]??e):e}function R(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const z={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function B(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[V(i)]=a)}return Object.keys(t).length>0?t:void 0}function V(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function H(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}Object.defineProperty(exports
|
|
1
|
+
const e=require("./helpers-AzWOnvQd.cjs"),t={html:{display:`block`},head:{display:`none`},meta:{display:`none`},title:{display:`none`},link:{display:`none`},style:{display:`none`},script:{display:`none`},body:{margin:8,display:`block`},p:{marginTop:`1em`,marginBottom:`1em`,display:`block`},blockquote:{marginTop:`1em`,marginBottom:`1em`,marginLeft:40,marginRight:40,display:`block`},figure:{marginTop:`1em`,marginBottom:`1em`,marginLeft:40,marginRight:40,display:`block`},figcaption:{display:`block`},address:{fontStyle:`italic`,display:`block`},article:{display:`block`},aside:{display:`block`},footer:{display:`block`},header:{display:`block`},hgroup:{display:`block`},main:{display:`block`},nav:{display:`block`},section:{display:`block`},center:{textAlign:`center`,display:`block`},hr:{marginTop:`0.5em`,marginBottom:`0.5em`,marginLeft:`auto`,marginRight:`auto`,borderWidth:1,display:`block`},h1:{fontSize:`2em`,marginTop:`0.67em`,marginBottom:`0.67em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h2:{fontSize:`1.5em`,marginTop:`0.83em`,marginBottom:`0.83em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h3:{fontSize:`1.17em`,marginTop:`1em`,marginBottom:`1em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h4:{marginTop:`1.33em`,marginBottom:`1.33em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h5:{fontSize:`0.83em`,marginTop:`1.67em`,marginBottom:`1.67em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h6:{fontSize:`0.67em`,marginTop:`2.33em`,marginBottom:`2.33em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},u:{textDecoration:`underline`},strong:{fontWeight:`bold`},b:{fontWeight:`bold`},i:{fontStyle:`italic`},em:{fontStyle:`italic`},cite:{fontStyle:`italic`},dfn:{fontStyle:`italic`},code:{fontFamily:`monospace`},kbd:{fontFamily:`monospace`},samp:{fontFamily:`monospace`},pre:{fontFamily:`monospace`,whiteSpace:`pre`,margin:`1em 0`,display:`block`},mark:{backgroundColor:`yellow`,color:`black`},big:{fontSize:`1.2em`},small:{fontSize:`0.8em`},s:{textDecoration:`line-through`},div:{display:`block`}};function n(e){if(e!==!1)return e??t}function r(e,t){let n;for(let r in e){if(!Object.hasOwn(e,r))continue;let i=e[r];r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n??={},n[r]=i===!0?``:String(i))}return n}var i=Symbol(`Fragment`),a=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),o=new Set([`script`,`style`]),s=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,c=/[\@\.a-z0-9_\:\-]/i;function l(e){let t={};if(e){let n=`none`,r,i=``,a,o;for(let s=0;s<e.length;s++){let l=e[s];n===`none`?c.test(l)?(r&&(t[r]=i,r=void 0,i=``),a=s,n=`key`):l===`=`&&r&&(n=`value`):n===`key`?c.test(l)||(r=e.substring(a,s),n=l===`=`?`value`:`none`):l===o&&s>0&&e[s-1]!==`\\`?o&&(i=e.substring(a,s),o=void 0,n=`none`):(l===`"`||l===`'`)&&!o&&(a=s+1,o=l)}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function u(e){let t=typeof e==`string`?e:e.value,n,r,i,c,u,d,f,p,m,h=[];s.lastIndex=0,r=n={type:0,children:[]};let g=0;function _(){c=t.substring(g,s.lastIndex-i[0].length),c&&r.children.push({type:2,value:c,parent:r})}for(;i=s.exec(t);){if(d=i[5]||i[8],f=i[6]||i[9],p=i[7]||i[10],o.has(r.name)&&i[2]!==r.name){u=s.lastIndex-i[0].length,r.children.length>0&&(r.children[0].value+=i[0]);continue}else if(d===`<!--`){if(u=s.lastIndex-i[0].length,o.has(r.name))continue;m={type:3,value:f,parent:r,loc:[{start:u,end:u+d.length},{start:s.lastIndex-p.length,end:s.lastIndex}]},h.push(m),m.parent.children.push(m)}else if(d===`<!`)u=s.lastIndex-i[0].length,m={type:4,value:f,parent:r,loc:[{start:u,end:u+d.length},{start:s.lastIndex-p.length,end:s.lastIndex}]},h.push(m),m.parent.children.push(m);else if(i[1]!==`/`)if(_(),o.has(r.name)){g=s.lastIndex,_();continue}else m={type:1,name:i[2]+``,attributes:l(i[3]),parent:r,children:[],loc:[{start:s.lastIndex-i[0].length,end:s.lastIndex}]},h.push(m),m.parent.children.push(m),i[4]&&i[4].indexOf(`/`)>-1||a.has(m.name)?(m.loc[1]=m.loc[0],m.isSelfClosingTag=!0):r=m;else _(),i[2]+``===r.name?(m=r,r=m.parent,m.loc.push({start:s.lastIndex-i[0].length,end:s.lastIndex}),c=t.substring(m.loc[0].end,m.loc[1].start),m.children.length===0&&m.children.push({type:2,value:c,parent:r})):i[2]+``===h[h.length-1].name&&h[h.length-1].isSelfClosingTag===!0&&(m=h[h.length-1],m.loc.push({start:s.lastIndex-i[0].length,end:s.lastIndex}));g=s.lastIndex}return c=t.slice(g),r.children.push({type:2,value:c,parent:r}),n}var d=Symbol(`HTMLString`),f=Symbol(`AttrString`),p=Symbol(`RenderFn`);function m(e,t=[d]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var h={"&":`&`,"<":`<`,">":`>`};function g(e){return e.replace(/[&<>]/g,e=>h[e]||e)}function _(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return m(t,[d,f])}function v(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function y(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>b(e)).join(``);if(p in e){let t=e[p](n,m(r));return t&&t[d]?t.value:g(String(t))}if(t===i)return r;let o=v(e);return o||a.has(t)?`<${e.name}${_(n).value}${o?` /`:``}>`:`<${e.name}${_(n).value}>${r}</${e.name}>`}function b(e){switch(e.type){case 0:return e.children.map(e=>b(e)).join(``);case 1:return y(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}const x=new Set([`head`,`meta`,`link`,`style`,`script`]);function S(e){return x.has(e)}function C(e,t){return e.type===t&&`props`in e}function w(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}function T(e){return typeof e==`object`&&!!e&&`type`in e}function E(e){return typeof e==`function`}const D=Symbol.for(`react.forward_ref`),O=Symbol.for(`react.memo`),k=Symbol.for(`react.fragment`);function A(e){return e.$$typeof===D}function j(e){return e.$$typeof===O}function M(e){return e.type===k}function N(e,t){let r=u(e),i={nodes:[],stylesheets:[]},a=n(t?.defaultStyles),o=t?.tailwindClassesProperty??`tw`;for(let e of r.children)P(e,a,o,i.nodes,i.stylesheets);return i}function P(t,n,r,i,a){if(t.type===3)return;if(t.type===2){let r=t.value??``;r&&i.push(e.l({text:r,preset:n?.span}));return}if(t.type===0){for(let e of t.children)P(e,n,r,i,a);return}if(t.type!==1)return;let o=t;if(o.name===`style`){let e=``;for(let t of o.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&a.push(e);return}let s=F(o,n,r);if(o.name===`br`){i.push(e.l({text:`
|
|
2
|
+
`,preset:n?.span,...s}));return}if(o.name===`img`){let t=o.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);i.push(e.i({src:t,width:H(o.attributes?.width),height:H(o.attributes?.height),...s}));return}if(S(o.name))return;if(o.name===`svg`){i.push(e.i({src:b(o),width:H(o.attributes?.width),height:H(o.attributes?.height),...s}));return}let c=!0,l=``;for(let e of o.children)if(e.type!==3){if(e.type!==2){c=!1;break}l+=e.value??``}if(c&&l){i.push(e.l({text:l,...s}));return}let u=[];for(let e of o.children)P(e,n,r,u,a);i.push(e.t({children:u,...s}))}function F(e,t,n){let i=e.attributes?I(e.attributes):{},a=typeof i.style==`string`?B(i.style):void 0,o=r(i,n),s=typeof i[n]==`string`?i[n]:void 0,c=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:i.class,id:i.id,dir:i.dir,attributes:o,tw:s,style:a,preset:c}}function I(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=L(r))}return t}function L(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?R(Number(t))??e:n?R(Number.parseInt(n,16))??e:z[r]??e):e}function R(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const z={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function B(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[V(i)]=a)}return Object.keys(t).length>0?t:void 0}function V(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function H(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"d",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"f",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"l",{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return w}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return E}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return M}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return N}}),Object.defineProperty(exports,"u",{enumerable:!0,get:function(){return r}});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{i as e,l as t,t as n}from"./helpers-
|
|
1
|
+
import{i as e,l as t,t as n}from"./helpers-CqeNg4sp.mjs";const r={html:{display:`block`},head:{display:`none`},meta:{display:`none`},title:{display:`none`},link:{display:`none`},style:{display:`none`},script:{display:`none`},body:{margin:8,display:`block`},p:{marginTop:`1em`,marginBottom:`1em`,display:`block`},blockquote:{marginTop:`1em`,marginBottom:`1em`,marginLeft:40,marginRight:40,display:`block`},figure:{marginTop:`1em`,marginBottom:`1em`,marginLeft:40,marginRight:40,display:`block`},figcaption:{display:`block`},address:{fontStyle:`italic`,display:`block`},article:{display:`block`},aside:{display:`block`},footer:{display:`block`},header:{display:`block`},hgroup:{display:`block`},main:{display:`block`},nav:{display:`block`},section:{display:`block`},center:{textAlign:`center`,display:`block`},hr:{marginTop:`0.5em`,marginBottom:`0.5em`,marginLeft:`auto`,marginRight:`auto`,borderWidth:1,display:`block`},h1:{fontSize:`2em`,marginTop:`0.67em`,marginBottom:`0.67em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h2:{fontSize:`1.5em`,marginTop:`0.83em`,marginBottom:`0.83em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h3:{fontSize:`1.17em`,marginTop:`1em`,marginBottom:`1em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h4:{marginTop:`1.33em`,marginBottom:`1.33em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h5:{fontSize:`0.83em`,marginTop:`1.67em`,marginBottom:`1.67em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},h6:{fontSize:`0.67em`,marginTop:`2.33em`,marginBottom:`2.33em`,marginLeft:0,marginRight:0,fontWeight:`bold`,display:`block`},u:{textDecoration:`underline`},strong:{fontWeight:`bold`},b:{fontWeight:`bold`},i:{fontStyle:`italic`},em:{fontStyle:`italic`},cite:{fontStyle:`italic`},dfn:{fontStyle:`italic`},code:{fontFamily:`monospace`},kbd:{fontFamily:`monospace`},samp:{fontFamily:`monospace`},pre:{fontFamily:`monospace`,whiteSpace:`pre`,margin:`1em 0`,display:`block`},mark:{backgroundColor:`yellow`,color:`black`},big:{fontSize:`1.2em`},small:{fontSize:`0.8em`},s:{textDecoration:`line-through`},div:{display:`block`}};function i(e){if(e!==!1)return e??r}function a(e,t){let n;for(let r in e){if(!Object.hasOwn(e,r))continue;let i=e[r];r===`children`||r===`className`||r===`class`||r===`id`||r===`style`||r===t||r===`ref`||r===`key`||r===`dangerouslySetInnerHTML`||r===`suppressHydrationWarning`||i==null||i===!1||typeof i==`function`||typeof i==`symbol`||typeof i!=`object`&&(n??={},n[r]=i===!0?``:String(i))}return n}var o=Symbol(`Fragment`),s=new Set([`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),c=new Set([`script`,`style`]),l=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,u=/[\@\.a-z0-9_\:\-]/i;function d(e){let t={};if(e){let n=`none`,r,i=``,a,o;for(let s=0;s<e.length;s++){let c=e[s];n===`none`?u.test(c)?(r&&(t[r]=i,r=void 0,i=``),a=s,n=`key`):c===`=`&&r&&(n=`value`):n===`key`?u.test(c)||(r=e.substring(a,s),n=c===`=`?`value`:`none`):c===o&&s>0&&e[s-1]!==`\\`?o&&(i=e.substring(a,s),o=void 0,n=`none`):(c===`"`||c===`'`)&&!o&&(a=s+1,o=c)}n===`key`&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=i)}return t}function f(e){let t=typeof e==`string`?e:e.value,n,r,i,a,o,u,f,p,m,h=[];l.lastIndex=0,r=n={type:0,children:[]};let g=0;function _(){a=t.substring(g,l.lastIndex-i[0].length),a&&r.children.push({type:2,value:a,parent:r})}for(;i=l.exec(t);){if(u=i[5]||i[8],f=i[6]||i[9],p=i[7]||i[10],c.has(r.name)&&i[2]!==r.name){o=l.lastIndex-i[0].length,r.children.length>0&&(r.children[0].value+=i[0]);continue}else if(u===`<!--`){if(o=l.lastIndex-i[0].length,c.has(r.name))continue;m={type:3,value:f,parent:r,loc:[{start:o,end:o+u.length},{start:l.lastIndex-p.length,end:l.lastIndex}]},h.push(m),m.parent.children.push(m)}else if(u===`<!`)o=l.lastIndex-i[0].length,m={type:4,value:f,parent:r,loc:[{start:o,end:o+u.length},{start:l.lastIndex-p.length,end:l.lastIndex}]},h.push(m),m.parent.children.push(m);else if(i[1]!==`/`)if(_(),c.has(r.name)){g=l.lastIndex,_();continue}else m={type:1,name:i[2]+``,attributes:d(i[3]),parent:r,children:[],loc:[{start:l.lastIndex-i[0].length,end:l.lastIndex}]},h.push(m),m.parent.children.push(m),i[4]&&i[4].indexOf(`/`)>-1||s.has(m.name)?(m.loc[1]=m.loc[0],m.isSelfClosingTag=!0):r=m;else _(),i[2]+``===r.name?(m=r,r=m.parent,m.loc.push({start:l.lastIndex-i[0].length,end:l.lastIndex}),a=t.substring(m.loc[0].end,m.loc[1].start),m.children.length===0&&m.children.push({type:2,value:a,parent:r})):i[2]+``===h[h.length-1].name&&h[h.length-1].isSelfClosingTag===!0&&(m=h[h.length-1],m.loc.push({start:l.lastIndex-i[0].length,end:l.lastIndex}));g=l.lastIndex}return a=t.slice(g),r.children.push({type:2,value:a,parent:r}),n}var p=Symbol(`HTMLString`),m=Symbol(`AttrString`),h=Symbol(`RenderFn`);function g(e,t=[p]){let n={value:e};for(let e of t)Object.defineProperty(n,e,{value:!0,enumerable:!1,writable:!1});return n}var _={"&":`&`,"<":`<`,">":`>`};function v(e){return e.replace(/[&<>]/g,e=>_[e]||e)}function y(e){let t=``;for(let[n,r]of Object.entries(e))t+=` ${n}="${r}"`;return g(t,[p,m])}function b(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name===`svg`)return!0}return!1}function x(e){let{name:t,attributes:n={}}=e,r=e.children.map(e=>S(e)).join(``);if(h in e){let t=e[h](n,g(r));return t&&t[p]?t.value:v(String(t))}if(t===o)return r;let i=b(e);return i||s.has(t)?`<${e.name}${y(n).value}${i?` /`:``}>`:`<${e.name}${y(n).value}>${r}</${e.name}>`}function S(e){switch(e.type){case 0:return e.children.map(e=>S(e)).join(``);case 1:return x(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}const C=new Set([`head`,`meta`,`link`,`style`,`script`]);function w(e){return C.has(e)}function T(e,t){return e.type===t&&`props`in e}function E(e){return e.replace(/([A-Z])/g,`-$1`).toLowerCase()}function D(e){return typeof e==`object`&&!!e&&`type`in e}function O(e){return typeof e==`function`}const k=Symbol.for(`react.forward_ref`),A=Symbol.for(`react.memo`),j=Symbol.for(`react.fragment`);function M(e){return e.$$typeof===k}function N(e){return e.$$typeof===A}function P(e){return e.type===j}function F(e,t){let n=f(e),r={nodes:[],stylesheets:[]},a=i(t?.defaultStyles),o=t?.tailwindClassesProperty??`tw`;for(let e of n.children)I(e,a,o,r.nodes,r.stylesheets);return r}function I(r,i,a,o,s){if(r.type===3)return;if(r.type===2){let e=r.value??``;e&&o.push(t({text:e,preset:i?.span}));return}if(r.type===0){for(let e of r.children)I(e,i,a,o,s);return}if(r.type!==1)return;let c=r;if(c.name===`style`){let e=``;for(let t of c.children)t.type===2&&typeof t.value==`string`&&(e+=t.value);e&&s.push(e);return}let l=L(c,i,a);if(c.name===`br`){o.push(t({text:`
|
|
2
2
|
`,preset:i?.span,...l}));return}if(c.name===`img`){let t=c.attributes?.src;if(!t)throw Error(`Image element must have a 'src' prop.`);o.push(e({src:t,width:W(c.attributes?.width),height:W(c.attributes?.height),...l}));return}if(w(c.name))return;if(c.name===`svg`){o.push(e({src:S(c),width:W(c.attributes?.width),height:W(c.attributes?.height),...l}));return}let u=!0,d=``;for(let e of c.children)if(e.type!==3){if(e.type!==2){u=!1;break}d+=e.value??``}if(u&&d){o.push(t({text:d,...l}));return}let f=[];for(let e of c.children)I(e,i,a,f,s);o.push(n({children:f,...l}))}function L(e,t,n){let r=e.attributes?R(e.attributes):{},i=typeof r.style==`string`?H(r.style):void 0,o=a(r,n),s=typeof r[n]==`string`?r[n]:void 0,c=t&&e.name in t?t[e.name]:void 0;return{tagName:e.name,className:r.class,id:r.id,dir:r.dir,attributes:o,tw:s,style:i,preset:c}}function R(e){let t={};for(let n in e){let r=e[n];r!==void 0&&(t[n]=z(r))}return t}function z(e){return e.includes(`&`)?e.replace(/&(?:#(\d+)|#x([\da-fA-F]+)|([a-zA-Z][\w-]+));/g,(e,t,n,r)=>t?B(Number(t))??e:n?B(Number.parseInt(n,16))??e:V[r]??e):e}function B(e){if(!(!Number.isInteger(e)||e<0||e>1114111))try{return String.fromCodePoint(e)}catch{return}}const V={amp:`&`,apos:`'`,gt:`>`,lt:`<`,nbsp:`\xA0`,quot:`"`};function H(e){let t={};for(let n of e.split(`;`)){let[e,...r]=n.split(`:`);if(!e||r.length===0)continue;let i=e.trim(),a=r.join(`:`).trim();!i||!a||(t[U(i)]=a)}return Object.keys(t).length>0?t:void 0}function U(e){return e.startsWith(`--`)?e:e.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}function W(e){if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}export{w as a,N as c,i as d,r as f,T as i,D as l,E as n,M as o,O as r,P as s,F as t,a as u};
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Value of the `text-fit` longhand: `[ none | grow | shrink ] [ consistent | per-line | per-line-all ]? <percentage>?`.
|
|
6
|
+
*
|
|
7
|
+
* @see https://drafts.csswg.org/css-text-4/#text-fit-property
|
|
8
|
+
*/
|
|
9
|
+
type TextFit = "none" | "grow" | "shrink" | "consistent" | "per-line" | "per-line-all" | `${number}%` | (string & {});
|
|
10
|
+
declare module "react" {
|
|
11
|
+
interface CSSProperties {
|
|
12
|
+
textFit?: TextFit;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
4
15
|
type NodeAttributes = Record<string, string>;
|
|
5
16
|
type ReactElementLike = {
|
|
6
17
|
type: string | symbol | ((props: unknown) => ReactElementLike) | ReactElementLike;
|
|
@@ -33,4 +44,4 @@ type ImageNode = NodeMetadata & {
|
|
|
33
44
|
height?: number;
|
|
34
45
|
};
|
|
35
46
|
//#endregion
|
|
36
|
-
export { NodeMetadata as a, NodeAttributes as i, ImageNode as n, ReactElementLike as o, Node as r,
|
|
47
|
+
export { NodeMetadata as a, TextNode as c, NodeAttributes as i, ImageNode as n, ReactElementLike as o, Node as r, TextFit as s, ContainerNode as t };
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
2
|
|
|
3
3
|
//#region src/types.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Value of the `text-fit` longhand: `[ none | grow | shrink ] [ consistent | per-line | per-line-all ]? <percentage>?`.
|
|
6
|
+
*
|
|
7
|
+
* @see https://drafts.csswg.org/css-text-4/#text-fit-property
|
|
8
|
+
*/
|
|
9
|
+
type TextFit = "none" | "grow" | "shrink" | "consistent" | "per-line" | "per-line-all" | `${number}%` | (string & {});
|
|
10
|
+
declare module "react" {
|
|
11
|
+
interface CSSProperties {
|
|
12
|
+
textFit?: TextFit;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
4
15
|
type NodeAttributes = Record<string, string>;
|
|
5
16
|
type ReactElementLike = {
|
|
6
17
|
type: string | symbol | ((props: unknown) => ReactElementLike) | ReactElementLike;
|
|
@@ -33,4 +44,4 @@ type ImageNode = NodeMetadata & {
|
|
|
33
44
|
height?: number;
|
|
34
45
|
};
|
|
35
46
|
//#endregion
|
|
36
|
-
export { NodeMetadata as a, NodeAttributes as i, ImageNode as n, ReactElementLike as o, Node as r,
|
|
47
|
+
export { NodeMetadata as a, TextNode as c, NodeAttributes as i, ImageNode as n, ReactElementLike as o, Node as r, TextFit as s, ContainerNode as t };
|
package/package.json
CHANGED
|
File without changes
|