@takumi-rs/helpers 2.0.0 → 2.0.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.
package/dist/emoji.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { r as Node } from "./types-xgX3CGse.cjs";
2
-
1
+ import { r as Node } from "./types-BZASl6ra.cjs";
3
2
  //#region src/emoji.d.ts
4
3
  type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji" | "fluent" | "fluentFlat";
5
4
  declare function extractEmojis(node: Node, emojiType: EmojiType): Node;
package/dist/emoji.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { r as Node } from "./types-xgX3CGse.mjs";
2
-
1
+ import { r as Node } from "./types-BZASl6ra.mjs";
3
2
  //#region src/emoji.d.ts
4
3
  type EmojiType = "twemoji" | "blobmoji" | "noto" | "openmoji" | "fluent" | "fluentFlat";
5
4
  declare function extractEmojis(node: Node, emojiType: EmojiType): Node;
@@ -0,0 +1 @@
1
+ const e=32*1024*1024,t=/url\(\s*(['"]?)(.*?)\1\s*\)/g;async function n(e,t={}){if(t.allowUrl&&!t.allowUrl(e))throw Error(`URL blocked by allowUrl policy: ${e}`);let n=t.fetch??globalThis.fetch,r=t.timeout??5e3,i=r<=0?void 0:AbortSignal.timeout(r),a=[t.signal,t.init?.signal,i].filter(e=>e!==void 0),o=a.length?AbortSignal.any(a):void 0,s=await n(e,{...t.init,signal:o});if(!s.ok)throw Error(`HTTP ${s.status} ${s.statusText} fetching ${e}`);return s}async function r(e,t){let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>t)throw Error(`Response exceeds ${t} bytes (content-length ${n})`);let r=e.body;if(!r)return e.arrayBuffer();let i=r.getReader(),a=[],o=0;for(;;){let{done:e,value:n}=await i.read();if(e)break;if(o+=n.byteLength,o>t)throw await i.cancel().catch(()=>{}),Error(`Response exceeds ${t} bytes`);a.push(n)}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.byteLength;return s.buffer}function i(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function a(e,n){if(typeof e==`string`)for(let r of e.matchAll(t)){let e=r[2]?.trim();e&&i(e)&&n.add(e)}else if(Array.isArray(e))for(let t of e)a(t,n)}function o(e){let t=new Set,n=e=>{let r=e=>{e&&(a(e.backgroundImage,t),a(e.maskImage,t))};if(r(e.style),r(e.preset),a(e.tw,t),e.type===`image`){typeof e.src==`string`&&i(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}function s(e,t,i){let a=i?.get(e);if(a)return a;let o=n(e,t).then(e=>r(e,t.maxBytes??33554432)).catch(t=>{throw i?.delete(e),t});return i?.set(e,o),o}async function c({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:a,maxBytes:c,allowUrl:l,throwOnError:u=!0}){let d=Array.isArray(e)?e:[e],f=new Map;for(let e of t)f.set(e.src,e);let p=[...new Set(d.flatMap(o))].filter(e=>!f.has(e)),m={fetch:r,timeout:i,signal:a,maxBytes:c,allowUrl:l},h=p.map(async e=>({src:e,data:await s(e,m,n)})),g=u?await Promise.all(h):(await Promise.allSettled(h)).filter(e=>e.status===`fulfilled`).map(e=>e.value);return[...f.values(),...g]}const l=new Map;function u(e,t,n,r){let i=new Map(r),a=n.includes(`italic`),o=a?n.includes(`normal`)?[0,1]:[1]:[void 0],s=[...a?[`ital`]:[],...i.keys(),`wght`].sort(),c=o.flatMap(e=>t.map(t=>s.map(n=>n===`ital`?String(e):n===`wght`?t:i.get(n)??``).join(`,`))).sort();return`${e}:${s.join(`,`)}@${c.join(`;`)}`}function d(e){let t=new URL(e.baseUrl??`https://fonts.googleapis.com/css2`);for(let n of e.families){if(typeof n==`string`){t.searchParams.append(`family`,u(n,[`400`],[`normal`],[]));continue}let e=n.weight??400,r=(Array.isArray(e)?[...e].sort((e,t)=>e-t):[e]).map(String),i=n.style??`normal`,a=(Array.isArray(i)?i:[i]).map(String),o=Object.entries(n.axes??{}).filter(([e])=>e!==`ital`&&e!==`wght`).map(([e,t])=>[e,String(t)]);t.searchParams.append(`family`,u(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function f(e,t){return n(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=>r(e,t.maxBytes??2097152)).then(e=>new TextDecoder().decode(e))}function p(e,t){let n=t.cache??l,r=n.get(e);if(r)return r;let i=f(e,t);return n.set(e,i),i.catch(()=>n.delete(e)),i}const m=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function h(e,t){let i=`${e.family} ${e.subset}`,a=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:i,subsetOf:e.family,key:`${i}:${e.weight??``}:${e.style??``}:${a}`,weight:e.weight,style:e.style,ranges:e.ranges,data:()=>n(e.url,t).then(e=>r(e,t.maxBytes??33554432))}}function g(e){let t=[];for(let n of e.split(`,`)){let e=n.trim().replace(/^U\+/i,``);if(e)if(e.includes(`-`)){let[n,r]=e.split(`-`);n&&r&&t.push([parseInt(n,16),parseInt(r,16)])}else if(e.includes(`?`))t.push([parseInt(e.replace(/\?/g,`0`),16),parseInt(e.replace(/\?/g,`F`),16)]);else{let n=parseInt(e,16);t.push([n,n])}}return t}function _(e){let t=[],n=0;for(let r of e.matchAll(m)){let e=r[2];if(!e)continue;let i=e.match(/src:\s*url\(([^)]+)\)/)?.[1]?.replace(/['"]/g,``).trim(),a=e.match(/font-family:\s*['"]?([^'";]+)['"]?/)?.[1]?.trim();if(!i||!a)continue;let o=e.match(/unicode-range:\s*([^;]+)/)?.[1],s=e.match(/font-weight:\s*(\d+)(?:\s+(\d+))?/);t.push({family:a,subset:r[1]?.trim()||`subset-${n}`,url:i,weight:s&&!s[2]?Number(s[1]):void 0,style:e.match(/font-style:\s*([a-z]+)/i)?.[1],ranges:o?g(o):[]}),n+=1}return t}function v(e){let t=new Map;for(let n of e){let e=t.get(n.url)??new Set;e.add(n.weight),t.set(n.url,e)}let n=new Set,r=[];for(let i of e){if(n.has(i.url))continue;n.add(i.url);let e=(t.get(i.url)?.size??0)>1;r.push(e?{...i,weight:void 0}:i)}return r}function y(e){let t=new Set,n=e=>{for(let n of e)t.add(n.codePointAt(0))},r=e=>{e.type===`text`?n(e.text):e.type===`container`&&e.children?.forEach(r)};return typeof e==`string`?n(e):Array.isArray(e)?e.forEach(r):r(e),t}function b(e,t){if(e.length===0)return!0;for(let n of t)for(let[t,r]of e)if(n>=t&&n<=r)return!0;return!1}function x({fonts:e,source:t}){let n=y(t);return e.filter(e=>b(e.ranges??[],n))}function S(e,t={}){return{key:e,data:()=>n(e,t).then(e=>r(e,t.maxBytes??33554432))}}async function C(e){if(Array.isArray(e)&&(e={families:e}),e.families.length===0)return[];let t=await p(d(e),e),n=new Map(e.families.map((e,t)=>[typeof e==`string`?e:e.name,t]));return v(_(t)).sort((e,t)=>(n.get(e.family)??0)-(n.get(t.family)??0)).map(t=>h(t,e))}export{e as a,r as c,x as i,S as n,n as o,C as r,c as s,y as t};
@@ -0,0 +1 @@
1
+ const e=/url\(\s*(['"]?)(.*?)\1\s*\)/g;async function t(e,t={}){if(t.allowUrl&&!t.allowUrl(e))throw Error(`URL blocked by allowUrl policy: ${e}`);let n=t.fetch??globalThis.fetch,r=t.timeout??5e3,i=r<=0?void 0:AbortSignal.timeout(r),a=[t.signal,t.init?.signal,i].filter(e=>e!==void 0),o=a.length?AbortSignal.any(a):void 0,s=await n(e,{...t.init,signal:o});if(!s.ok)throw Error(`HTTP ${s.status} ${s.statusText} fetching ${e}`);return s}async function n(e,t){let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>t)throw Error(`Response exceeds ${t} bytes (content-length ${n})`);let r=e.body;if(!r)return e.arrayBuffer();let i=r.getReader(),a=[],o=0;for(;;){let{done:e,value:n}=await i.read();if(e)break;if(o+=n.byteLength,o>t)throw await i.cancel().catch(()=>{}),Error(`Response exceeds ${t} bytes`);a.push(n)}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.byteLength;return s.buffer}function r(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function i(t,n){if(typeof t==`string`)for(let i of t.matchAll(e)){let e=i[2]?.trim();e&&r(e)&&n.add(e)}else if(Array.isArray(t))for(let e of t)i(e,n)}function a(e){let t=new Set,n=e=>{let a=e=>{e&&(i(e.backgroundImage,t),i(e.maskImage,t))};if(a(e.style),a(e.preset),i(e.tw,t),e.type===`image`){typeof e.src==`string`&&r(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}function o(e,r,i){let a=i?.get(e);if(a)return a;let o=t(e,r).then(e=>n(e,r.maxBytes??33554432)).catch(t=>{throw i?.delete(e),t});return i?.set(e,o),o}async function s({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:s,maxBytes:c,allowUrl:l,throwOnError:u=!0}){let d=Array.isArray(e)?e:[e],f=new Map;for(let e of t)f.set(e.src,e);let p=[...new Set(d.flatMap(a))].filter(e=>!f.has(e)),m={fetch:r,timeout:i,signal:s,maxBytes:c,allowUrl:l},h=p.map(async e=>({src:e,data:await o(e,m,n)})),g=u?await Promise.all(h):(await Promise.allSettled(h)).filter(e=>e.status===`fulfilled`).map(e=>e.value);return[...f.values(),...g]}const c=new Map;function l(e,t,n,r){let i=new Map(r),a=n.includes(`italic`),o=a?n.includes(`normal`)?[0,1]:[1]:[void 0],s=[...a?[`ital`]:[],...i.keys(),`wght`].sort(),c=o.flatMap(e=>t.map(t=>s.map(n=>n===`ital`?String(e):n===`wght`?t:i.get(n)??``).join(`,`))).sort();return`${e}:${s.join(`,`)}@${c.join(`;`)}`}function u(e){let t=new URL(e.baseUrl??`https://fonts.googleapis.com/css2`);for(let n of e.families){if(typeof n==`string`){t.searchParams.append(`family`,l(n,[`400`],[`normal`],[]));continue}let e=n.weight??400,r=(Array.isArray(e)?[...e].sort((e,t)=>e-t):[e]).map(String),i=n.style??`normal`,a=(Array.isArray(i)?i:[i]).map(String),o=Object.entries(n.axes??{}).filter(([e])=>e!==`ital`&&e!==`wght`).map(([e,t])=>[e,String(t)]);t.searchParams.append(`family`,l(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function d(e,r){return t(e,{...r,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=>n(e,r.maxBytes??2097152)).then(e=>new TextDecoder().decode(e))}function f(e,t){let n=t.cache??c,r=n.get(e);if(r)return r;let i=d(e,t);return n.set(e,i),i.catch(()=>n.delete(e)),i}const p=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function m(e,r){let i=`${e.family} ${e.subset}`,a=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:i,subsetOf:e.family,key:`${i}:${e.weight??``}:${e.style??``}:${a}`,weight:e.weight,style:e.style,ranges:e.ranges,data:()=>t(e.url,r).then(e=>n(e,r.maxBytes??33554432))}}function h(e){let t=[];for(let n of e.split(`,`)){let e=n.trim().replace(/^U\+/i,``);if(e)if(e.includes(`-`)){let[n,r]=e.split(`-`);n&&r&&t.push([parseInt(n,16),parseInt(r,16)])}else if(e.includes(`?`))t.push([parseInt(e.replace(/\?/g,`0`),16),parseInt(e.replace(/\?/g,`F`),16)]);else{let n=parseInt(e,16);t.push([n,n])}}return t}function g(e){let t=[],n=0;for(let r of e.matchAll(p)){let e=r[2];if(!e)continue;let i=e.match(/src:\s*url\(([^)]+)\)/)?.[1]?.replace(/['"]/g,``).trim(),a=e.match(/font-family:\s*['"]?([^'";]+)['"]?/)?.[1]?.trim();if(!i||!a)continue;let o=e.match(/unicode-range:\s*([^;]+)/)?.[1],s=e.match(/font-weight:\s*(\d+)(?:\s+(\d+))?/);t.push({family:a,subset:r[1]?.trim()||`subset-${n}`,url:i,weight:s&&!s[2]?Number(s[1]):void 0,style:e.match(/font-style:\s*([a-z]+)/i)?.[1],ranges:o?h(o):[]}),n+=1}return t}function _(e){let t=new Map;for(let n of e){let e=t.get(n.url)??new Set;e.add(n.weight),t.set(n.url,e)}let n=new Set,r=[];for(let i of e){if(n.has(i.url))continue;n.add(i.url);let e=(t.get(i.url)?.size??0)>1;r.push(e?{...i,weight:void 0}:i)}return r}function v(e){let t=new Set,n=e=>{for(let n of e)t.add(n.codePointAt(0))},r=e=>{e.type===`text`?n(e.text):e.type===`container`&&e.children?.forEach(r)};return typeof e==`string`?n(e):Array.isArray(e)?e.forEach(r):r(e),t}function y(e,t){if(e.length===0)return!0;for(let n of t)for(let[t,r]of e)if(n>=t&&n<=r)return!0;return!1}function b({fonts:e,source:t}){let n=v(t);return e.filter(e=>y(e.ranges??[],n))}function x(e,r={}){return{key:e,data:()=>t(e,r).then(e=>n(e,r.maxBytes??33554432))}}async function S(e){if(Array.isArray(e)&&(e={families:e}),e.families.length===0)return[];let t=await f(u(e),e),n=new Map(e.families.map((e,t)=>[typeof e==`string`?e:e.name,t]));return _(g(t)).sort((e,t)=>(n.get(e.family)??0)-(n.get(t.family)??0)).map(t=>m(t,e))}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return 33554432}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
package/dist/html.d.cts CHANGED
@@ -1,4 +1,5 @@
1
- import { r as Node } from "./types-xgX3CGse.cjs";
1
+ import { r as Node } from "./types-BZASl6ra.cjs";
2
+ import "./index-iLIV_qDx.cjs";
2
3
  //#region src/html/index.d.ts
3
4
  declare function fromHtml(html: string): {
4
5
  node: Node;
package/dist/html.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { r as Node } from "./types-xgX3CGse.mjs";
1
+ import { r as Node } from "./types-BZASl6ra.mjs";
2
+ import "./index-DO_-sEIA.mjs";
2
3
  //#region src/html/index.d.ts
3
4
  declare function fromHtml(html: string): {
4
5
  node: Node;
@@ -1,6 +1,5 @@
1
- import { c as TextNode, n as ImageNode, r as Node, t as ContainerNode } from "./types-xgX3CGse.mjs";
1
+ import { c as TextNode, n as ImageNode, r as Node, t as ContainerNode } from "./types-BZASl6ra.mjs";
2
2
  import { CSSProperties } from "react";
3
-
4
3
  //#region src/google-fonts-catalog.d.ts
5
4
  interface GoogleFontShapes {
6
5
  S0: {
@@ -923,10 +922,15 @@ interface GoogleFontShapeFamilies {
923
922
  declare const defaultMaxFetchBytes: number;
924
923
  type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
925
924
  type FetchOptions = {
926
- /** Custom fetch implementation. @default globalThis.fetch */fetch?: FetchLike; /** Abort the request after this many milliseconds; `0` or negative disables it. @default 5000 */
927
- timeout?: number; /** Caller abort signal, combined with the timeout. */
928
- signal?: AbortSignal; /** Reject bodies larger than this many bytes. @default 33554432 (32 MiB) */
929
- maxBytes?: number; /** Return false to skip fetching a URL (e.g. SSRF allowlist). */
925
+ /** Custom fetch implementation. @default globalThis.fetch */
926
+ fetch?: FetchLike;
927
+ /** Abort the request after this many milliseconds; `0` or negative disables it. @default 5000 */
928
+ timeout?: number;
929
+ /** Caller abort signal, combined with the timeout. */
930
+ signal?: AbortSignal;
931
+ /** Reject bodies larger than this many bytes. @default 33554432 (32 MiB) */
932
+ maxBytes?: number;
933
+ /** Return false to skip fetching a URL (e.g. SSRF allowlist). */
930
934
  allowUrl?: (url: string) => boolean;
931
935
  };
932
936
  /** Fetches a URL, applying a timeout signal and throwing on a non-OK status. */
@@ -953,9 +957,13 @@ interface FetchedImage {
953
957
  type PrepareImagesOptions<T extends {
954
958
  src: string;
955
959
  } = FetchedImage> = FetchOptions & {
956
- /** The node tree(s) whose remote images to fetch. */node: Node | Node[]; /** Pre-fetched entries; their URLs are not re-fetched. */
957
- sources?: T[]; /** Single-flight byte cache shared across renders. */
958
- fetchCache?: ImageFetchCache; /** Throw on any fetch failure; if `false`, failed URLs are dropped. @default true */
960
+ /** The node tree(s) whose remote images to fetch. */
961
+ node: Node | Node[];
962
+ /** Pre-fetched entries; their URLs are not re-fetched. */
963
+ sources?: T[];
964
+ /** Single-flight byte cache shared across renders. */
965
+ fetchCache?: ImageFetchCache;
966
+ /** Throw on any fetch failure; if `false`, failed URLs are dropped. @default true */
959
967
  throwOnError?: boolean;
960
968
  };
961
969
  /**
@@ -964,28 +972,21 @@ type PrepareImagesOptions<T extends {
964
972
  */
965
973
  declare function prepareImages<T extends {
966
974
  src: string;
967
- } = FetchedImage>({
968
- node,
969
- sources,
970
- fetchCache,
971
- fetch,
972
- timeout,
973
- signal,
974
- maxBytes,
975
- allowUrl,
976
- throwOnError
977
- }: PrepareImagesOptions<T>): Promise<(T | FetchedImage)[]>;
975
+ } = FetchedImage>({ node, sources, fetchCache, fetch, timeout, signal, maxBytes, allowUrl, throwOnError }: PrepareImagesOptions<T>): Promise<(T | FetchedImage)[]>;
978
976
  //#endregion
979
977
  //#region src/fonts.d.ts
980
978
  type FontStyle = "normal" | "italic";
981
979
  type WeightRange = `${number}..${number}`;
982
980
  type AxisValue = number | WeightRange;
983
981
  type KnownGoogleFontFamily = { [S in keyof GoogleFontShapes]: {
984
- name: GoogleFontShapeFamilies[S]; /** `400`, `[400, 700]`, or a range like `"100..900"` for the variable font. @default 400 */
985
- weight?: GoogleFontShapes[S]["weight"] | GoogleFontShapes[S]["weight"][] | WeightRange; /** `"normal"`, `"italic"`, or both. @default "normal" */
986
- style?: GoogleFontShapes[S]["style"] | GoogleFontShapes[S]["style"][]; /** Variable axes to vary, each at a value or `"min..max"` range, e.g. `{ opsz: "14..32" }`. */
982
+ name: GoogleFontShapeFamilies[S];
983
+ /** `400`, `[400, 700]`, or a range like `"100..900"` for the variable font. @default 400 */
984
+ weight?: GoogleFontShapes[S]["weight"] | GoogleFontShapes[S]["weight"][] | WeightRange;
985
+ /** `"normal"`, `"italic"`, or both. @default "normal" */
986
+ style?: GoogleFontShapes[S]["style"] | GoogleFontShapes[S]["style"][];
987
+ /** Variable axes to vary, each at a value or `"min..max"` range, e.g. `{ opsz: "14..32" }`. */
987
988
  axes?: [GoogleFontShapes[S]["axis"]] extends [never] ? never : Partial<Record<GoogleFontShapes[S]["axis"], AxisValue>>;
988
- } }[keyof GoogleFontShapes];
989
+ }; }[keyof GoogleFontShapes];
989
990
  type GoogleFontName = GoogleFontShapeFamilies[keyof GoogleFontShapeFamilies];
990
991
  /**
991
992
  * One family to load. A bare string loads weight 400, normal style. The object form autocompletes
@@ -999,12 +1000,15 @@ type GoogleFontFamily = GoogleFontName | (string & {}) | KnownGoogleFontFamily |
999
1000
  axes?: Record<string, AxisValue>;
1000
1001
  };
1001
1002
  type GoogleFontsOptions = FetchOptions & {
1002
- /** The families to load, each as a name or a name plus its weight/style axis. */families: GoogleFontFamily[]; /** `font-display` strategy passed through to the CSS request. */
1003
+ /** The families to load, each as a name or a name plus its weight/style axis. */
1004
+ families: GoogleFontFamily[];
1005
+ /** `font-display` strategy passed through to the CSS request. */
1003
1006
  display?: "auto" | "block" | "swap" | "fallback" | "optional";
1004
1007
  /**
1005
- * Cache for the Google Fonts CSS, keyed by request URL. Reuse one across renders (e.g. a
1006
- * playground re-rendering on each edit) so the metadata is fetched and parsed once. Holds the
1007
- * in-flight promise, so concurrent calls share one request; failures evict themselves.
1008
+ * Cache for the Google Fonts CSS, keyed by request URL, so the metadata is fetched once across
1009
+ * renders (e.g. a playground re-rendering on each edit). Holds the in-flight promise, so
1010
+ * concurrent calls share one request; failures evict themselves. Defaults to a process-wide
1011
+ * cache; pass your own `Map` to scope it, or a fresh one per call to opt out.
1008
1012
  */
1009
1013
  cache?: Pick<Map<string, Promise<string>>, "get" | "set" | "delete">;
1010
1014
  /**
@@ -1015,12 +1019,17 @@ type GoogleFontsOptions = FetchOptions & {
1015
1019
  };
1016
1020
  /** A loaded font subset, ready to hand to a renderer's `fonts`. */
1017
1021
  type FontSubset = {
1018
- /** Unique internal family name (`"{family} {subset}"`); never written in CSS. */name: string; /** Logical family authors reference in `font-family`; expands to every loaded subset. */
1019
- subsetOf: string; /** Stable dedup key (`"{name}:{weight}:{style}:{range}"`), independent of the rotating woff2 URL. */
1022
+ /** Unique internal family name (`"{family} {subset}"`); never written in CSS. */
1023
+ name: string;
1024
+ /** Logical family authors reference in `font-family`; expands to every loaded subset. */
1025
+ subsetOf: string;
1026
+ /** Stable dedup key (`"{name}:{weight}:{style}:{range}"`), independent of the rotating woff2 URL. */
1020
1027
  key: string;
1021
1028
  weight?: number;
1022
- style?: string; /** Inclusive codepoint ranges this subset covers; empty covers everything. */
1023
- ranges: [number, number][]; /** Fetches the subset bytes. The renderer skips files it has already loaded. */
1029
+ style?: string;
1030
+ /** Inclusive codepoint ranges this subset covers; empty covers everything. */
1031
+ ranges: [number, number][];
1032
+ /** Fetches the subset bytes. The renderer skips files it has already loaded. */
1024
1033
  data: () => Promise<ArrayBuffer>;
1025
1034
  };
1026
1035
  /** Collect every codepoint the content will render. */
@@ -1030,10 +1039,7 @@ declare function collectCodepoints(source: string | Node | Node[]): Set<number>;
1030
1039
  * `text=` subset) always stay. Runs without network, so a renderer can apply it to the final
1031
1040
  * node tree. Works on any descriptor carrying `ranges`; entries without it are kept.
1032
1041
  */
1033
- declare function subsetFonts<T>({
1034
- fonts,
1035
- source
1036
- }: {
1042
+ declare function subsetFonts<T>({ fonts, source }: {
1037
1043
  fonts: T[];
1038
1044
  source: string | Node | Node[];
1039
1045
  }): T[];
@@ -1054,10 +1060,10 @@ declare function fontFromUrl(url: string, options?: FetchOptions): {
1054
1060
  * content uses; or trim them first with {@link subsetFonts}.
1055
1061
  *
1056
1062
  * @example
1057
- * const fonts = await googleFonts({ families: ["Inter", "Noto Sans JP"] });
1063
+ * const fonts = await googleFonts(["Inter", "Noto Sans JP"]);
1058
1064
  * await render(element, { width, height, fonts });
1059
1065
  */
1060
- declare function googleFonts(options: GoogleFontsOptions): Promise<FontSubset[]>;
1066
+ declare function googleFonts(options: GoogleFontsOptions | GoogleFontFamily[]): Promise<FontSubset[]>;
1061
1067
  //#endregion
1062
1068
  //#region src/helpers.d.ts
1063
1069
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
@@ -1,6 +1,5 @@
1
- import { c as TextNode, n as ImageNode, r as Node, t as ContainerNode } from "./types-xgX3CGse.cjs";
1
+ import { c as TextNode, n as ImageNode, r as Node, t as ContainerNode } from "./types-BZASl6ra.cjs";
2
2
  import { CSSProperties } from "react";
3
-
4
3
  //#region src/google-fonts-catalog.d.ts
5
4
  interface GoogleFontShapes {
6
5
  S0: {
@@ -923,10 +922,15 @@ interface GoogleFontShapeFamilies {
923
922
  declare const defaultMaxFetchBytes: number;
924
923
  type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
925
924
  type FetchOptions = {
926
- /** Custom fetch implementation. @default globalThis.fetch */fetch?: FetchLike; /** Abort the request after this many milliseconds; `0` or negative disables it. @default 5000 */
927
- timeout?: number; /** Caller abort signal, combined with the timeout. */
928
- signal?: AbortSignal; /** Reject bodies larger than this many bytes. @default 33554432 (32 MiB) */
929
- maxBytes?: number; /** Return false to skip fetching a URL (e.g. SSRF allowlist). */
925
+ /** Custom fetch implementation. @default globalThis.fetch */
926
+ fetch?: FetchLike;
927
+ /** Abort the request after this many milliseconds; `0` or negative disables it. @default 5000 */
928
+ timeout?: number;
929
+ /** Caller abort signal, combined with the timeout. */
930
+ signal?: AbortSignal;
931
+ /** Reject bodies larger than this many bytes. @default 33554432 (32 MiB) */
932
+ maxBytes?: number;
933
+ /** Return false to skip fetching a URL (e.g. SSRF allowlist). */
930
934
  allowUrl?: (url: string) => boolean;
931
935
  };
932
936
  /** Fetches a URL, applying a timeout signal and throwing on a non-OK status. */
@@ -953,9 +957,13 @@ interface FetchedImage {
953
957
  type PrepareImagesOptions<T extends {
954
958
  src: string;
955
959
  } = FetchedImage> = FetchOptions & {
956
- /** The node tree(s) whose remote images to fetch. */node: Node | Node[]; /** Pre-fetched entries; their URLs are not re-fetched. */
957
- sources?: T[]; /** Single-flight byte cache shared across renders. */
958
- fetchCache?: ImageFetchCache; /** Throw on any fetch failure; if `false`, failed URLs are dropped. @default true */
960
+ /** The node tree(s) whose remote images to fetch. */
961
+ node: Node | Node[];
962
+ /** Pre-fetched entries; their URLs are not re-fetched. */
963
+ sources?: T[];
964
+ /** Single-flight byte cache shared across renders. */
965
+ fetchCache?: ImageFetchCache;
966
+ /** Throw on any fetch failure; if `false`, failed URLs are dropped. @default true */
959
967
  throwOnError?: boolean;
960
968
  };
961
969
  /**
@@ -964,28 +972,21 @@ type PrepareImagesOptions<T extends {
964
972
  */
965
973
  declare function prepareImages<T extends {
966
974
  src: string;
967
- } = FetchedImage>({
968
- node,
969
- sources,
970
- fetchCache,
971
- fetch,
972
- timeout,
973
- signal,
974
- maxBytes,
975
- allowUrl,
976
- throwOnError
977
- }: PrepareImagesOptions<T>): Promise<(T | FetchedImage)[]>;
975
+ } = FetchedImage>({ node, sources, fetchCache, fetch, timeout, signal, maxBytes, allowUrl, throwOnError }: PrepareImagesOptions<T>): Promise<(T | FetchedImage)[]>;
978
976
  //#endregion
979
977
  //#region src/fonts.d.ts
980
978
  type FontStyle = "normal" | "italic";
981
979
  type WeightRange = `${number}..${number}`;
982
980
  type AxisValue = number | WeightRange;
983
981
  type KnownGoogleFontFamily = { [S in keyof GoogleFontShapes]: {
984
- name: GoogleFontShapeFamilies[S]; /** `400`, `[400, 700]`, or a range like `"100..900"` for the variable font. @default 400 */
985
- weight?: GoogleFontShapes[S]["weight"] | GoogleFontShapes[S]["weight"][] | WeightRange; /** `"normal"`, `"italic"`, or both. @default "normal" */
986
- style?: GoogleFontShapes[S]["style"] | GoogleFontShapes[S]["style"][]; /** Variable axes to vary, each at a value or `"min..max"` range, e.g. `{ opsz: "14..32" }`. */
982
+ name: GoogleFontShapeFamilies[S];
983
+ /** `400`, `[400, 700]`, or a range like `"100..900"` for the variable font. @default 400 */
984
+ weight?: GoogleFontShapes[S]["weight"] | GoogleFontShapes[S]["weight"][] | WeightRange;
985
+ /** `"normal"`, `"italic"`, or both. @default "normal" */
986
+ style?: GoogleFontShapes[S]["style"] | GoogleFontShapes[S]["style"][];
987
+ /** Variable axes to vary, each at a value or `"min..max"` range, e.g. `{ opsz: "14..32" }`. */
987
988
  axes?: [GoogleFontShapes[S]["axis"]] extends [never] ? never : Partial<Record<GoogleFontShapes[S]["axis"], AxisValue>>;
988
- } }[keyof GoogleFontShapes];
989
+ }; }[keyof GoogleFontShapes];
989
990
  type GoogleFontName = GoogleFontShapeFamilies[keyof GoogleFontShapeFamilies];
990
991
  /**
991
992
  * One family to load. A bare string loads weight 400, normal style. The object form autocompletes
@@ -999,12 +1000,15 @@ type GoogleFontFamily = GoogleFontName | (string & {}) | KnownGoogleFontFamily |
999
1000
  axes?: Record<string, AxisValue>;
1000
1001
  };
1001
1002
  type GoogleFontsOptions = FetchOptions & {
1002
- /** The families to load, each as a name or a name plus its weight/style axis. */families: GoogleFontFamily[]; /** `font-display` strategy passed through to the CSS request. */
1003
+ /** The families to load, each as a name or a name plus its weight/style axis. */
1004
+ families: GoogleFontFamily[];
1005
+ /** `font-display` strategy passed through to the CSS request. */
1003
1006
  display?: "auto" | "block" | "swap" | "fallback" | "optional";
1004
1007
  /**
1005
- * Cache for the Google Fonts CSS, keyed by request URL. Reuse one across renders (e.g. a
1006
- * playground re-rendering on each edit) so the metadata is fetched and parsed once. Holds the
1007
- * in-flight promise, so concurrent calls share one request; failures evict themselves.
1008
+ * Cache for the Google Fonts CSS, keyed by request URL, so the metadata is fetched once across
1009
+ * renders (e.g. a playground re-rendering on each edit). Holds the in-flight promise, so
1010
+ * concurrent calls share one request; failures evict themselves. Defaults to a process-wide
1011
+ * cache; pass your own `Map` to scope it, or a fresh one per call to opt out.
1008
1012
  */
1009
1013
  cache?: Pick<Map<string, Promise<string>>, "get" | "set" | "delete">;
1010
1014
  /**
@@ -1015,12 +1019,17 @@ type GoogleFontsOptions = FetchOptions & {
1015
1019
  };
1016
1020
  /** A loaded font subset, ready to hand to a renderer's `fonts`. */
1017
1021
  type FontSubset = {
1018
- /** Unique internal family name (`"{family} {subset}"`); never written in CSS. */name: string; /** Logical family authors reference in `font-family`; expands to every loaded subset. */
1019
- subsetOf: string; /** Stable dedup key (`"{name}:{weight}:{style}:{range}"`), independent of the rotating woff2 URL. */
1022
+ /** Unique internal family name (`"{family} {subset}"`); never written in CSS. */
1023
+ name: string;
1024
+ /** Logical family authors reference in `font-family`; expands to every loaded subset. */
1025
+ subsetOf: string;
1026
+ /** Stable dedup key (`"{name}:{weight}:{style}:{range}"`), independent of the rotating woff2 URL. */
1020
1027
  key: string;
1021
1028
  weight?: number;
1022
- style?: string; /** Inclusive codepoint ranges this subset covers; empty covers everything. */
1023
- ranges: [number, number][]; /** Fetches the subset bytes. The renderer skips files it has already loaded. */
1029
+ style?: string;
1030
+ /** Inclusive codepoint ranges this subset covers; empty covers everything. */
1031
+ ranges: [number, number][];
1032
+ /** Fetches the subset bytes. The renderer skips files it has already loaded. */
1024
1033
  data: () => Promise<ArrayBuffer>;
1025
1034
  };
1026
1035
  /** Collect every codepoint the content will render. */
@@ -1030,10 +1039,7 @@ declare function collectCodepoints(source: string | Node | Node[]): Set<number>;
1030
1039
  * `text=` subset) always stay. Runs without network, so a renderer can apply it to the final
1031
1040
  * node tree. Works on any descriptor carrying `ranges`; entries without it are kept.
1032
1041
  */
1033
- declare function subsetFonts<T>({
1034
- fonts,
1035
- source
1036
- }: {
1042
+ declare function subsetFonts<T>({ fonts, source }: {
1037
1043
  fonts: T[];
1038
1044
  source: string | Node | Node[];
1039
1045
  }): T[];
@@ -1054,10 +1060,10 @@ declare function fontFromUrl(url: string, options?: FetchOptions): {
1054
1060
  * content uses; or trim them first with {@link subsetFonts}.
1055
1061
  *
1056
1062
  * @example
1057
- * const fonts = await googleFonts({ families: ["Inter", "Noto Sans JP"] });
1063
+ * const fonts = await googleFonts(["Inter", "Noto Sans JP"]);
1058
1064
  * await render(element, { width, height, fonts });
1059
1065
  */
1060
- declare function googleFonts(options: GoogleFontsOptions): Promise<FontSubset[]>;
1066
+ declare function googleFonts(options: GoogleFontsOptions | GoogleFontFamily[]): Promise<FontSubset[]>;
1061
1067
  //#endregion
1062
1068
  //#region src/helpers.d.ts
1063
1069
  declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-9PAJBFPs.cjs"),t=require("./helpers-4kGcvc-Q.cjs");exports.collectCodepoints=e.t,exports.container=t.t,exports.defaultMaxFetchBytes=e.a,exports.em=t.n,exports.fetchOk=e.o,exports.fontFromUrl=e.n,exports.fr=t.r,exports.googleFonts=e.r,exports.image=t.i,exports.percentage=t.a,exports.prepareImages=e.s,exports.readBodyLimited=e.c,exports.rem=t.o,exports.rgba=t.s,exports.style=t.c,exports.subsetFonts=e.i,exports.text=t.l,exports.vh=t.u,exports.vw=t.d;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-uO6HxxV0.cjs"),t=require("./helpers-4kGcvc-Q.cjs");exports.collectCodepoints=e.t,exports.container=t.t,exports.defaultMaxFetchBytes=e.a,exports.em=t.n,exports.fetchOk=e.o,exports.fontFromUrl=e.n,exports.fr=t.r,exports.googleFonts=e.r,exports.image=t.i,exports.percentage=t.a,exports.prepareImages=e.s,exports.readBodyLimited=e.c,exports.rem=t.o,exports.rgba=t.s,exports.style=t.c,exports.subsetFonts=e.i,exports.text=t.l,exports.vh=t.u,exports.vw=t.d;
package/dist/index.d.cts CHANGED
@@ -1,3 +1,3 @@
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-xgX3CGse.cjs";
2
- import { C as PrepareImagesOptions, D as readBodyLimited, E as prepareImages, S as ImageFetchCache, T as fetchOk, _ as googleFonts, a as percentage, b as FetchOptions, c as style, d as vw, f as FontSubset, g as fontFromUrl, h as collectCodepoints, i as image, l as text, m as GoogleFontsOptions, n as em, o as rem, p as GoogleFontFamily, r as fr, s as rgba, t as container, u as vh, v as subsetFonts, w as defaultMaxFetchBytes, x as FetchedImage, y as FetchLike } from "./index-CsUeQ4__.cjs";
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-BZASl6ra.cjs";
2
+ import { C as PrepareImagesOptions, D as readBodyLimited, E as prepareImages, S as ImageFetchCache, T as fetchOk, _ as googleFonts, a as percentage, b as FetchOptions, c as style, d as vw, f as FontSubset, g as fontFromUrl, h as collectCodepoints, i as image, l as text, m as GoogleFontsOptions, n as em, o as rem, p as GoogleFontFamily, r as fr, s as rgba, t as container, u as vh, v as subsetFonts, w as defaultMaxFetchBytes, x as FetchedImage, y as FetchLike } from "./index-iLIV_qDx.cjs";
3
3
  export { ContainerNode, FetchLike, FetchOptions, FetchedImage, FontSubset, GoogleFontFamily, GoogleFontsOptions, ImageFetchCache, ImageNode, Node, NodeAttributes, NodeMetadata, PrepareImagesOptions, ReactElementLike, TextFit, TextNode, collectCodepoints, container, defaultMaxFetchBytes, em, fetchOk, fontFromUrl, fr, googleFonts, image, percentage, prepareImages, readBodyLimited, rem, rgba, style, subsetFonts, text, vh, vw };
package/dist/index.d.mts CHANGED
@@ -1,3 +1,3 @@
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-xgX3CGse.mjs";
2
- import { C as PrepareImagesOptions, D as readBodyLimited, E as prepareImages, S as ImageFetchCache, T as fetchOk, _ as googleFonts, a as percentage, b as FetchOptions, c as style, d as vw, f as FontSubset, g as fontFromUrl, h as collectCodepoints, i as image, l as text, m as GoogleFontsOptions, n as em, o as rem, p as GoogleFontFamily, r as fr, s as rgba, t as container, u as vh, v as subsetFonts, w as defaultMaxFetchBytes, x as FetchedImage, y as FetchLike } from "./index-B_CCO9JF.mjs";
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-BZASl6ra.mjs";
2
+ import { C as PrepareImagesOptions, D as readBodyLimited, E as prepareImages, S as ImageFetchCache, T as fetchOk, _ as googleFonts, a as percentage, b as FetchOptions, c as style, d as vw, f as FontSubset, g as fontFromUrl, h as collectCodepoints, i as image, l as text, m as GoogleFontsOptions, n as em, o as rem, p as GoogleFontFamily, r as fr, s as rgba, t as container, u as vh, v as subsetFonts, w as defaultMaxFetchBytes, x as FetchedImage, y as FetchLike } from "./index-DO_-sEIA.mjs";
3
3
  export { ContainerNode, FetchLike, FetchOptions, FetchedImage, FontSubset, GoogleFontFamily, GoogleFontsOptions, ImageFetchCache, ImageNode, Node, NodeAttributes, NodeMetadata, PrepareImagesOptions, ReactElementLike, TextFit, TextNode, collectCodepoints, container, defaultMaxFetchBytes, em, fetchOk, fontFromUrl, fr, googleFonts, image, percentage, prepareImages, readBodyLimited, rem, rgba, style, subsetFonts, text, vh, vw };
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./fonts-DRl6tDqK.mjs";import{a as c,c as l,d as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./helpers-CVQCT1Rh.mjs";export{s as collectCodepoints,_ as container,e as defaultMaxFetchBytes,p as em,i as fetchOk,r as fontFromUrl,h as fr,a as googleFonts,d as image,c as percentage,o as prepareImages,t as readBodyLimited,m as rem,g as rgba,l as style,n as subsetFonts,f as text,v as vh,u as vw};
1
+ import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./fonts-B4N9qU8h.mjs";import{a as c,c as l,d as u,i as d,l as f,n as p,o as m,r as h,s as g,t as _,u as v}from"./helpers-CVQCT1Rh.mjs";export{s as collectCodepoints,_ as container,e as defaultMaxFetchBytes,p as em,i as fetchOk,r as fontFromUrl,h as fr,a as googleFonts,d as image,c as percentage,o as prepareImages,t as readBodyLimited,m as rem,g as rgba,l as style,n as subsetFonts,f as text,v as vh,u as vw};
package/dist/jsx.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.cjs"),t=require("./markup-uM2dO3dn.cjs");function n(e){return typeof e==`string`||typeof e==`number`}function r(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}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=[],r=!1;for(let i of e){if(t.l(i))return;if(typeof i==`string`){r=!0,n.push(i);continue}if(typeof i==`number`){r=!0,n.push(String(i));continue}return}if(r)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:`
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.cjs"),t=require("./markup-uM2dO3dn.cjs");function n(e){return typeof e==`string`||typeof e==`number`}function r(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}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))}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=[],r=!1;for(let i of e){if(t.l(i))return;if(typeof i==`string`){r=!0,n.push(i);continue}if(typeof i==`number`){r=!0,n.push(String(i));continue}return}if(r)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,lang:r.lang,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
@@ -1,6 +1,5 @@
1
- import { o as ReactElementLike, r as Node } from "./types-xgX3CGse.cjs";
1
+ import { o as ReactElementLike, r as Node } from "./types-BZASl6ra.cjs";
2
2
  import { CSSProperties, JSX, ReactNode } from "react";
3
-
4
3
  //#region src/jsx/style-presets.d.ts
5
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
6
5
  //#endregion
package/dist/jsx.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { o as ReactElementLike, r as Node } from "./types-xgX3CGse.mjs";
1
+ import { o as ReactElementLike, r as Node } from "./types-BZASl6ra.mjs";
2
2
  import { CSSProperties, JSX, ReactNode } from "react";
3
-
4
3
  //#region src/jsx/style-presets.d.ts
5
4
  declare const defaultStylePresets: Partial<Record<keyof JSX.IntrinsicElements, CSSProperties>>;
6
5
  //#endregion
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-CVQCT1Rh.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-D58RlLsR.mjs";function g(e){return typeof e==`string`||typeof e==`number`}function _(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}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=[],n=!1;for(let r of e){if(l(r))return;if(typeof r==`string`){n=!0,t.push(r);continue}if(typeof r==`number`){n=!0,t.push(String(r));continue}return}if(n)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:`
1
+ import{a as e,i as t,l as n,t as r}from"./helpers-CVQCT1Rh.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-D58RlLsR.mjs";function g(e){return typeof e==`string`||typeof e==`number`}function _(e){return e.replace(/&/g,`&amp;`).replace(/"/g,`&quot;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}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))}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=[],n=!1;for(let r of e){if(l(r))return;if(typeof r==`string`){n=!0,t.push(r);continue}if(typeof r==`number`){n=!0,t.push(String(r));continue}return}if(n)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,lang:n.lang,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};
package/dist/renderer.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-9PAJBFPs.cjs");function t(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function n(e){return t(e)?e:typeof e.data==`function`?e.data():e.data}function r(e){return t(e)?e:`key`in e&&e.key?e.key:typeof e.data==`function`?`${e.name??``}:${e.weight??``}:${e.style??``}`:e.data}async function i(e){let{sources:t=[],cache:n}=Array.isArray(e)?{sources:e}:e,r=new Map;for(let e of t)r.set(e.src,e);return Promise.all([...r.values()].map(async({src:e,data:t,cache:r})=>({src:e,data:typeof t==`function`?await t():t,cache:r??n})))}var a=class{registerInner;byKey=new Map;byData=new WeakMap;constructor(e){this.registerInner=e}getFont(e){return typeof e==`string`?this.byKey.get(e):this.byData.get(e)}setFont(e,t){typeof e==`string`?this.byKey.set(e,t):this.byData.set(e,t)}deleteFont(e){typeof e==`string`?this.byKey.delete(e):this.byData.delete(e)}async register(i){let a=typeof i==`string`?e.n(i):i,o=r(a),s=this.getFont(o);if(s)return s;let c=n(a),l=Promise.resolve(c).then(e=>this.registerInner(t(a)?e:{...a,data:e})).catch(e=>{throw this.deleteFont(o),e});return this.setFont(o,l),l}async prepareFonts(e){if(!e)return;let t=await Promise.all(e.map(e=>this.register(e)));return[...new Set(t.flat().map(e=>e.name))]}async resolveResources(e,t,n){let r=await this.prepareFonts(e);return{images:t?await i(t):void 0,fontFamilies:n??r}}};async function o(t,n,r){let{fonts:i,fontFamilies:a,signal:o,images:s,...c}=n;o?.throwIfAborted();let l=await t.resolveResources(i&&e.i({fonts:i,source:r}),s,a);return o?.throwIfAborted(),{options:{...c,...l},signal:o}}exports.FontRegistry=a,exports.prepareRenderInput=o,exports.resolveImageLoaders=i;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-uO6HxxV0.cjs");function t(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function n(e){return t(e)?e:typeof e.data==`function`?e.data():e.data}function r(e){return t(e)?e:`key`in e&&e.key?e.key:typeof e.data==`function`?`${e.name??``}:${e.weight??``}:${e.style??``}`:e.data}async function i(e){let{sources:t=[],cache:n}=Array.isArray(e)?{sources:e}:e,r=new Map;for(let e of t)r.set(e.src,e);return Promise.all([...r.values()].map(async({src:e,data:t,cache:r})=>({src:e,data:typeof t==`function`?await t():t,cache:r??n})))}var a=class{registerInner;byKey=new Map;byData=new WeakMap;constructor(e){this.registerInner=e}getFont(e){return typeof e==`string`?this.byKey.get(e):this.byData.get(e)}setFont(e,t){typeof e==`string`?this.byKey.set(e,t):this.byData.set(e,t)}deleteFont(e){typeof e==`string`?this.byKey.delete(e):this.byData.delete(e)}async register(i){let a=typeof i==`string`?e.n(i):i,o=r(a),s=this.getFont(o);if(s)return s;let c=n(a),l=Promise.resolve(c).then(e=>this.registerInner(t(a)?e:{...a,data:e})).catch(e=>{throw this.deleteFont(o),e});return this.setFont(o,l),l}async prepareFonts(e){if(!e)return;let t=await Promise.all(e.map(e=>this.register(e)));return[...new Set(t.flat().map(e=>e.name))]}async resolveResources(e,t,n){let r=await this.prepareFonts(e);return{images:t?await i(t):void 0,fontFamilies:n??r}}};async function o(t,n,r){let{fonts:i,fontFamilies:a,signal:o,images:s,...c}=n;o?.throwIfAborted();let l=await i,u=await t.resolveResources(l&&e.i({fonts:l,source:r}),s,a);return o?.throwIfAborted(),{options:{...c,...u},signal:o}}exports.FontRegistry=a,exports.prepareRenderInput=o,exports.resolveImageLoaders=i;
@@ -1,5 +1,4 @@
1
- import { r as Node } from "./types-xgX3CGse.cjs";
2
-
1
+ import { r as Node } from "./types-BZASl6ra.cjs";
3
2
  //#region src/renderer.d.ts
4
3
  /**
5
4
  * Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
@@ -44,7 +43,8 @@ type RegisteredFamilyLike = {
44
43
  * file), raw bytes, or a descriptor with a lazy `data()` loader.
45
44
  */
46
45
  type FontLoader = string | Font | (Omit<FontDetails, "data"> & {
47
- data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
46
+ data: () => Promise<FontDetails["data"]> | FontDetails["data"];
47
+ /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
48
48
  ranges?: [number, number][];
49
49
  } & ({
50
50
  key: string;
@@ -56,7 +56,9 @@ type ImageLoader = Omit<ImageSource, "data"> & {
56
56
  };
57
57
  /** Images for a render: pre-fetched entries, or a group with a decode-cache default. */
58
58
  type ImagesInput = ImageLoader[] | {
59
- /** Pre-fetched entries, same as the array form. */sources?: ImageLoader[]; /** Decode-cache default for every image this render; a source's own `cache` wins. */
59
+ /** Pre-fetched entries, same as the array form. */
60
+ sources?: ImageLoader[];
61
+ /** Decode-cache default for every image this render; a source's own `cache` wins. */
60
62
  cache?: NonNullable<ImageLoader["cache"]>;
61
63
  };
62
64
  /**
@@ -96,7 +98,7 @@ type AnimationOutputFormatOptions = {
96
98
  };
97
99
  /** The wrapper-managed extras every render entry point accepts on top of the binding options. */
98
100
  type RenderExtras = {
99
- fonts?: FontLoader[];
101
+ fonts?: FontLoader[] | Promise<FontLoader[]>;
100
102
  signal?: AbortSignal;
101
103
  images?: ImagesInput;
102
104
  };
@@ -1,5 +1,4 @@
1
- import { r as Node } from "./types-xgX3CGse.mjs";
2
-
1
+ import { r as Node } from "./types-BZASl6ra.mjs";
3
2
  //#region src/renderer.d.ts
4
3
  /**
5
4
  * Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
@@ -44,7 +43,8 @@ type RegisteredFamilyLike = {
44
43
  * file), raw bytes, or a descriptor with a lazy `data()` loader.
45
44
  */
46
45
  type FontLoader = string | Font | (Omit<FontDetails, "data"> & {
47
- data: () => Promise<FontDetails["data"]> | FontDetails["data"]; /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
46
+ data: () => Promise<FontDetails["data"]> | FontDetails["data"];
47
+ /** Inclusive codepoint ranges this face covers; lets `render` skip it when unused. */
48
48
  ranges?: [number, number][];
49
49
  } & ({
50
50
  key: string;
@@ -56,7 +56,9 @@ type ImageLoader = Omit<ImageSource, "data"> & {
56
56
  };
57
57
  /** Images for a render: pre-fetched entries, or a group with a decode-cache default. */
58
58
  type ImagesInput = ImageLoader[] | {
59
- /** Pre-fetched entries, same as the array form. */sources?: ImageLoader[]; /** Decode-cache default for every image this render; a source's own `cache` wins. */
59
+ /** Pre-fetched entries, same as the array form. */
60
+ sources?: ImageLoader[];
61
+ /** Decode-cache default for every image this render; a source's own `cache` wins. */
60
62
  cache?: NonNullable<ImageLoader["cache"]>;
61
63
  };
62
64
  /**
@@ -96,7 +98,7 @@ type AnimationOutputFormatOptions = {
96
98
  };
97
99
  /** The wrapper-managed extras every render entry point accepts on top of the binding options. */
98
100
  type RenderExtras = {
99
- fonts?: FontLoader[];
101
+ fonts?: FontLoader[] | Promise<FontLoader[]>;
100
102
  signal?: AbortSignal;
101
103
  images?: ImagesInput;
102
104
  };
package/dist/renderer.mjs CHANGED
@@ -1 +1 @@
1
- import{i as e,n as t}from"./fonts-DRl6tDqK.mjs";function n(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function r(e){return n(e)?e:typeof e.data==`function`?e.data():e.data}function i(e){return n(e)?e:`key`in e&&e.key?e.key:typeof e.data==`function`?`${e.name??``}:${e.weight??``}:${e.style??``}`:e.data}async function a(e){let{sources:t=[],cache:n}=Array.isArray(e)?{sources:e}:e,r=new Map;for(let e of t)r.set(e.src,e);return Promise.all([...r.values()].map(async({src:e,data:t,cache:r})=>({src:e,data:typeof t==`function`?await t():t,cache:r??n})))}var o=class{registerInner;byKey=new Map;byData=new WeakMap;constructor(e){this.registerInner=e}getFont(e){return typeof e==`string`?this.byKey.get(e):this.byData.get(e)}setFont(e,t){typeof e==`string`?this.byKey.set(e,t):this.byData.set(e,t)}deleteFont(e){typeof e==`string`?this.byKey.delete(e):this.byData.delete(e)}async register(e){let a=typeof e==`string`?t(e):e,o=i(a),s=this.getFont(o);if(s)return s;let c=r(a),l=Promise.resolve(c).then(e=>this.registerInner(n(a)?e:{...a,data:e})).catch(e=>{throw this.deleteFont(o),e});return this.setFont(o,l),l}async prepareFonts(e){if(!e)return;let t=await Promise.all(e.map(e=>this.register(e)));return[...new Set(t.flat().map(e=>e.name))]}async resolveResources(e,t,n){let r=await this.prepareFonts(e);return{images:t?await a(t):void 0,fontFamilies:n??r}}};async function s(t,n,r){let{fonts:i,fontFamilies:a,signal:o,images:s,...c}=n;o?.throwIfAborted();let l=await t.resolveResources(i&&e({fonts:i,source:r}),s,a);return o?.throwIfAborted(),{options:{...c,...l},signal:o}}export{o as FontRegistry,s as prepareRenderInput,a as resolveImageLoaders};
1
+ import{i as e,n as t}from"./fonts-B4N9qU8h.mjs";function n(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function r(e){return n(e)?e:typeof e.data==`function`?e.data():e.data}function i(e){return n(e)?e:`key`in e&&e.key?e.key:typeof e.data==`function`?`${e.name??``}:${e.weight??``}:${e.style??``}`:e.data}async function a(e){let{sources:t=[],cache:n}=Array.isArray(e)?{sources:e}:e,r=new Map;for(let e of t)r.set(e.src,e);return Promise.all([...r.values()].map(async({src:e,data:t,cache:r})=>({src:e,data:typeof t==`function`?await t():t,cache:r??n})))}var o=class{registerInner;byKey=new Map;byData=new WeakMap;constructor(e){this.registerInner=e}getFont(e){return typeof e==`string`?this.byKey.get(e):this.byData.get(e)}setFont(e,t){typeof e==`string`?this.byKey.set(e,t):this.byData.set(e,t)}deleteFont(e){typeof e==`string`?this.byKey.delete(e):this.byData.delete(e)}async register(e){let a=typeof e==`string`?t(e):e,o=i(a),s=this.getFont(o);if(s)return s;let c=r(a),l=Promise.resolve(c).then(e=>this.registerInner(n(a)?e:{...a,data:e})).catch(e=>{throw this.deleteFont(o),e});return this.setFont(o,l),l}async prepareFonts(e){if(!e)return;let t=await Promise.all(e.map(e=>this.register(e)));return[...new Set(t.flat().map(e=>e.name))]}async resolveResources(e,t,n){let r=await this.prepareFonts(e);return{images:t?await a(t):void 0,fontFamilies:n??r}}};async function s(t,n,r){let{fonts:i,fontFamilies:a,signal:o,images:s,...c}=n;o?.throwIfAborted();let l=await i,u=await t.resolveResources(l&&e({fonts:l,source:r}),s,a);return o?.throwIfAborted(),{options:{...c,...u},signal:o}}export{o as FontRegistry,s as prepareRenderInput,a as resolveImageLoaders};
@@ -1,5 +1,4 @@
1
1
  import { CSSProperties } from "react";
2
-
3
2
  //#region src/types.d.ts
4
3
  /**
5
4
  * Value of the `text-fit` longhand: `[ none | grow | shrink ] [ consistent | per-line | per-line-all ]? <percentage>?`.
@@ -1,5 +1,4 @@
1
1
  import { CSSProperties } from "react";
2
-
3
2
  //#region src/types.d.ts
4
3
  /**
5
4
  * Value of the `text-fit` longhand: `[ none | grow | shrink ] [ consistent | per-line | per-line-all ]? <percentage>?`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Utility helpers for converting JSX/HTML to Takumi node trees, loading fonts, and processing emoji.",
5
5
  "keywords": [
6
6
  "css",
@@ -101,7 +101,7 @@
101
101
  "lucide-react": "^1.23.0",
102
102
  "react": "^19.2.7",
103
103
  "react-dom": "^19.2.7",
104
- "tsdown": "^0.22.3",
104
+ "tsdown": "^0.22.4",
105
105
  "ultrahtml": "^1.6.0",
106
106
  "unrun": "^0.3.1"
107
107
  },
@@ -1 +0,0 @@
1
- const e=/url\(\s*(['"]?)(.*?)\1\s*\)/g;async function t(e,t={}){if(t.allowUrl&&!t.allowUrl(e))throw Error(`URL blocked by allowUrl policy: ${e}`);let n=t.fetch??globalThis.fetch,r=t.timeout??5e3,i=r<=0?void 0:AbortSignal.timeout(r),a=[t.signal,t.init?.signal,i].filter(e=>e!==void 0),o=a.length?AbortSignal.any(a):void 0,s=await n(e,{...t.init,signal:o});if(!s.ok)throw Error(`HTTP ${s.status} ${s.statusText} fetching ${e}`);return s}async function n(e,t){let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>t)throw Error(`Response exceeds ${t} bytes (content-length ${n})`);let r=e.body;if(!r)return e.arrayBuffer();let i=r.getReader(),a=[],o=0;for(;;){let{done:e,value:n}=await i.read();if(e)break;if(o+=n.byteLength,o>t)throw await i.cancel().catch(()=>{}),Error(`Response exceeds ${t} bytes`);a.push(n)}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.byteLength;return s.buffer}function r(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function i(t,n){if(typeof t==`string`)for(let i of t.matchAll(e)){let e=i[2]?.trim();e&&r(e)&&n.add(e)}else if(Array.isArray(t))for(let e of t)i(e,n)}function a(e){let t=new Set,n=e=>{let a=e=>{e&&(i(e.backgroundImage,t),i(e.maskImage,t))};if(a(e.style),a(e.preset),i(e.tw,t),e.type===`image`){typeof e.src==`string`&&r(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}function o(e,r,i){let a=i?.get(e);if(a)return a;let o=t(e,r).then(e=>n(e,r.maxBytes??33554432)).catch(t=>{throw i?.delete(e),t});return i?.set(e,o),o}async function s({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:s,maxBytes:c,allowUrl:l,throwOnError:u=!0}){let d=Array.isArray(e)?e:[e],f=new Map;for(let e of t)f.set(e.src,e);let p=[...new Set(d.flatMap(a))].filter(e=>!f.has(e)),m={fetch:r,timeout:i,signal:s,maxBytes:c,allowUrl:l},h=p.map(async e=>({src:e,data:await o(e,m,n)})),g=u?await Promise.all(h):(await Promise.allSettled(h)).filter(e=>e.status===`fulfilled`).map(e=>e.value);return[...f.values(),...g]}function c(e,t,n,r){let i=new Map(r),a=n.includes(`italic`),o=a?n.includes(`normal`)?[0,1]:[1]:[void 0],s=[...a?[`ital`]:[],...i.keys(),`wght`].sort(),c=o.flatMap(e=>t.map(t=>s.map(n=>n===`ital`?String(e):n===`wght`?t:i.get(n)??``).join(`,`))).sort();return`${e}:${s.join(`,`)}@${c.join(`;`)}`}function l(e){let t=new URL(e.baseUrl??`https://fonts.googleapis.com/css2`);for(let n of e.families){if(typeof n==`string`){t.searchParams.append(`family`,c(n,[`400`],[`normal`],[]));continue}let e=n.weight??400,r=(Array.isArray(e)?[...e].sort((e,t)=>e-t):[e]).map(String),i=n.style??`normal`,a=(Array.isArray(i)?i:[i]).map(String),o=Object.entries(n.axes??{}).filter(([e])=>e!==`ital`&&e!==`wght`).map(([e,t])=>[e,String(t)]);t.searchParams.append(`family`,c(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function u(e,r){return t(e,{...r,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=>n(e,r.maxBytes??2097152)).then(e=>new TextDecoder().decode(e))}function d(e,t){let n=t.cache?.get(e);if(n)return n;let r=u(e,t);return t.cache&&(t.cache.set(e,r),r.catch(()=>t.cache?.delete(e))),r}const f=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function p(e,r){let i=`${e.family} ${e.subset}`,a=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:i,subsetOf:e.family,key:`${i}:${e.weight??``}:${e.style??``}:${a}`,weight:e.weight,style:e.style,ranges:e.ranges,data:()=>t(e.url,r).then(e=>n(e,r.maxBytes??33554432))}}function m(e){let t=[];for(let n of e.split(`,`)){let e=n.trim().replace(/^U\+/i,``);if(e)if(e.includes(`-`)){let[n,r]=e.split(`-`);n&&r&&t.push([parseInt(n,16),parseInt(r,16)])}else if(e.includes(`?`))t.push([parseInt(e.replace(/\?/g,`0`),16),parseInt(e.replace(/\?/g,`F`),16)]);else{let n=parseInt(e,16);t.push([n,n])}}return t}function h(e){let t=[],n=0;for(let r of e.matchAll(f)){let e=r[2];if(!e)continue;let i=e.match(/src:\s*url\(([^)]+)\)/)?.[1]?.replace(/['"]/g,``).trim(),a=e.match(/font-family:\s*['"]?([^'";]+)['"]?/)?.[1]?.trim();if(!i||!a)continue;let o=e.match(/unicode-range:\s*([^;]+)/)?.[1],s=e.match(/font-weight:\s*(\d+)(?:\s+(\d+))?/);t.push({family:a,subset:r[1]?.trim()||`subset-${n}`,url:i,weight:s&&!s[2]?Number(s[1]):void 0,style:e.match(/font-style:\s*([a-z]+)/i)?.[1],ranges:o?m(o):[]}),n+=1}return t}function g(e){let t=new Map;for(let n of e){let e=t.get(n.url)??new Set;e.add(n.weight),t.set(n.url,e)}let n=new Set,r=[];for(let i of e){if(n.has(i.url))continue;n.add(i.url);let e=(t.get(i.url)?.size??0)>1;r.push(e?{...i,weight:void 0}:i)}return r}function _(e){let t=new Set,n=e=>{for(let n of e)t.add(n.codePointAt(0))},r=e=>{e.type===`text`?n(e.text):e.type===`container`&&e.children?.forEach(r)};return typeof e==`string`?n(e):Array.isArray(e)?e.forEach(r):r(e),t}function v(e,t){if(e.length===0)return!0;for(let n of t)for(let[t,r]of e)if(n>=t&&n<=r)return!0;return!1}function y({fonts:e,source:t}){let n=_(t);return e.filter(e=>v(e.ranges??[],n))}function b(e,r={}){return{key:e,data:()=>t(e,r).then(e=>n(e,r.maxBytes??33554432))}}async function x(e){if(e.families.length===0)return[];let t=await d(l(e),e),n=new Map(e.families.map((e,t)=>[typeof e==`string`?e:e.name,t]));return g(h(t)).sort((e,t)=>(n.get(e.family)??0)-(n.get(t.family)??0)).map(t=>p(t,e))}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return 33554432}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return _}});
@@ -1 +0,0 @@
1
- const e=32*1024*1024,t=/url\(\s*(['"]?)(.*?)\1\s*\)/g;async function n(e,t={}){if(t.allowUrl&&!t.allowUrl(e))throw Error(`URL blocked by allowUrl policy: ${e}`);let n=t.fetch??globalThis.fetch,r=t.timeout??5e3,i=r<=0?void 0:AbortSignal.timeout(r),a=[t.signal,t.init?.signal,i].filter(e=>e!==void 0),o=a.length?AbortSignal.any(a):void 0,s=await n(e,{...t.init,signal:o});if(!s.ok)throw Error(`HTTP ${s.status} ${s.statusText} fetching ${e}`);return s}async function r(e,t){let n=Number(e.headers.get(`content-length`));if(Number.isFinite(n)&&n>t)throw Error(`Response exceeds ${t} bytes (content-length ${n})`);let r=e.body;if(!r)return e.arrayBuffer();let i=r.getReader(),a=[],o=0;for(;;){let{done:e,value:n}=await i.read();if(e)break;if(o+=n.byteLength,o>t)throw await i.cancel().catch(()=>{}),Error(`Response exceeds ${t} bytes`);a.push(n)}let s=new Uint8Array(o),c=0;for(let e of a)s.set(e,c),c+=e.byteLength;return s.buffer}function i(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function a(e,n){if(typeof e==`string`)for(let r of e.matchAll(t)){let e=r[2]?.trim();e&&i(e)&&n.add(e)}else if(Array.isArray(e))for(let t of e)a(t,n)}function o(e){let t=new Set,n=e=>{let r=e=>{e&&(a(e.backgroundImage,t),a(e.maskImage,t))};if(r(e.style),r(e.preset),a(e.tw,t),e.type===`image`){typeof e.src==`string`&&i(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}function s(e,t,i){let a=i?.get(e);if(a)return a;let o=n(e,t).then(e=>r(e,t.maxBytes??33554432)).catch(t=>{throw i?.delete(e),t});return i?.set(e,o),o}async function c({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:a,maxBytes:c,allowUrl:l,throwOnError:u=!0}){let d=Array.isArray(e)?e:[e],f=new Map;for(let e of t)f.set(e.src,e);let p=[...new Set(d.flatMap(o))].filter(e=>!f.has(e)),m={fetch:r,timeout:i,signal:a,maxBytes:c,allowUrl:l},h=p.map(async e=>({src:e,data:await s(e,m,n)})),g=u?await Promise.all(h):(await Promise.allSettled(h)).filter(e=>e.status===`fulfilled`).map(e=>e.value);return[...f.values(),...g]}function l(e,t,n,r){let i=new Map(r),a=n.includes(`italic`),o=a?n.includes(`normal`)?[0,1]:[1]:[void 0],s=[...a?[`ital`]:[],...i.keys(),`wght`].sort(),c=o.flatMap(e=>t.map(t=>s.map(n=>n===`ital`?String(e):n===`wght`?t:i.get(n)??``).join(`,`))).sort();return`${e}:${s.join(`,`)}@${c.join(`;`)}`}function u(e){let t=new URL(e.baseUrl??`https://fonts.googleapis.com/css2`);for(let n of e.families){if(typeof n==`string`){t.searchParams.append(`family`,l(n,[`400`],[`normal`],[]));continue}let e=n.weight??400,r=(Array.isArray(e)?[...e].sort((e,t)=>e-t):[e]).map(String),i=n.style??`normal`,a=(Array.isArray(i)?i:[i]).map(String),o=Object.entries(n.axes??{}).filter(([e])=>e!==`ital`&&e!==`wght`).map(([e,t])=>[e,String(t)]);t.searchParams.append(`family`,l(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function d(e,t){return n(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=>r(e,t.maxBytes??2097152)).then(e=>new TextDecoder().decode(e))}function f(e,t){let n=t.cache?.get(e);if(n)return n;let r=d(e,t);return t.cache&&(t.cache.set(e,r),r.catch(()=>t.cache?.delete(e))),r}const p=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function m(e,t){let i=`${e.family} ${e.subset}`,a=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:i,subsetOf:e.family,key:`${i}:${e.weight??``}:${e.style??``}:${a}`,weight:e.weight,style:e.style,ranges:e.ranges,data:()=>n(e.url,t).then(e=>r(e,t.maxBytes??33554432))}}function h(e){let t=[];for(let n of e.split(`,`)){let e=n.trim().replace(/^U\+/i,``);if(e)if(e.includes(`-`)){let[n,r]=e.split(`-`);n&&r&&t.push([parseInt(n,16),parseInt(r,16)])}else if(e.includes(`?`))t.push([parseInt(e.replace(/\?/g,`0`),16),parseInt(e.replace(/\?/g,`F`),16)]);else{let n=parseInt(e,16);t.push([n,n])}}return t}function g(e){let t=[],n=0;for(let r of e.matchAll(p)){let e=r[2];if(!e)continue;let i=e.match(/src:\s*url\(([^)]+)\)/)?.[1]?.replace(/['"]/g,``).trim(),a=e.match(/font-family:\s*['"]?([^'";]+)['"]?/)?.[1]?.trim();if(!i||!a)continue;let o=e.match(/unicode-range:\s*([^;]+)/)?.[1],s=e.match(/font-weight:\s*(\d+)(?:\s+(\d+))?/);t.push({family:a,subset:r[1]?.trim()||`subset-${n}`,url:i,weight:s&&!s[2]?Number(s[1]):void 0,style:e.match(/font-style:\s*([a-z]+)/i)?.[1],ranges:o?h(o):[]}),n+=1}return t}function _(e){let t=new Map;for(let n of e){let e=t.get(n.url)??new Set;e.add(n.weight),t.set(n.url,e)}let n=new Set,r=[];for(let i of e){if(n.has(i.url))continue;n.add(i.url);let e=(t.get(i.url)?.size??0)>1;r.push(e?{...i,weight:void 0}:i)}return r}function v(e){let t=new Set,n=e=>{for(let n of e)t.add(n.codePointAt(0))},r=e=>{e.type===`text`?n(e.text):e.type===`container`&&e.children?.forEach(r)};return typeof e==`string`?n(e):Array.isArray(e)?e.forEach(r):r(e),t}function y(e,t){if(e.length===0)return!0;for(let n of t)for(let[t,r]of e)if(n>=t&&n<=r)return!0;return!1}function b({fonts:e,source:t}){let n=v(t);return e.filter(e=>y(e.ranges??[],n))}function x(e,t={}){return{key:e,data:()=>n(e,t).then(e=>r(e,t.maxBytes??33554432))}}async function S(e){if(e.families.length===0)return[];let t=await f(u(e),e),n=new Map(e.families.map((e,t)=>[typeof e==`string`?e:e.name,t]));return _(g(t)).sort((e,t)=>(n.get(e.family)??0)-(n.get(t.family)??0)).map(t=>m(t,e))}export{e as a,r as c,b as i,x as n,n as o,S as r,c as s,v as t};