@takumi-rs/helpers 2.0.0-rc.1 → 2.0.0-rc.3
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.
|
@@ -2818,6 +2818,11 @@ interface GoogleFontCatalog {
|
|
|
2818
2818
|
style: "italic" | "normal";
|
|
2819
2819
|
axis: never;
|
|
2820
2820
|
};
|
|
2821
|
+
"Geist Pixel": {
|
|
2822
|
+
weight: 400;
|
|
2823
|
+
style: "normal";
|
|
2824
|
+
axis: "ELSH";
|
|
2825
|
+
};
|
|
2821
2826
|
"Gelasio": {
|
|
2822
2827
|
weight: 400 | 500 | 600 | 700;
|
|
2823
2828
|
style: "italic" | "normal";
|
|
@@ -4938,6 +4943,11 @@ interface GoogleFontCatalog {
|
|
|
4938
4943
|
style: "normal";
|
|
4939
4944
|
axis: never;
|
|
4940
4945
|
};
|
|
4946
|
+
"Montenegrin Gothic One": {
|
|
4947
|
+
weight: 400;
|
|
4948
|
+
style: "normal";
|
|
4949
|
+
axis: never;
|
|
4950
|
+
};
|
|
4941
4951
|
"Montez": {
|
|
4942
4952
|
weight: 400;
|
|
4943
4953
|
style: "normal";
|
|
@@ -9578,6 +9588,16 @@ interface GoogleFontCatalog {
|
|
|
9578
9588
|
style: "normal";
|
|
9579
9589
|
axis: never;
|
|
9580
9590
|
};
|
|
9591
|
+
"Yuyu": {
|
|
9592
|
+
weight: 400;
|
|
9593
|
+
style: "normal";
|
|
9594
|
+
axis: never;
|
|
9595
|
+
};
|
|
9596
|
+
"Yuyu Short": {
|
|
9597
|
+
weight: 400;
|
|
9598
|
+
style: "normal";
|
|
9599
|
+
axis: never;
|
|
9600
|
+
};
|
|
9581
9601
|
"ZCOOL KuaiLe": {
|
|
9582
9602
|
weight: 400;
|
|
9583
9603
|
style: "normal";
|
|
@@ -9751,6 +9771,11 @@ type GoogleFontsOptions = FetchOptions & {
|
|
|
9751
9771
|
* playground re-rendering on each edit) so the metadata is fetched and parsed once.
|
|
9752
9772
|
*/
|
|
9753
9773
|
cache?: Pick<Map<string, string>, "has" | "get" | "set">;
|
|
9774
|
+
/**
|
|
9775
|
+
* css2 base URL. Defaults to Google Fonts; point it at an API-compatible mirror like
|
|
9776
|
+
* `https://fonts.bunny.net/css2`.
|
|
9777
|
+
*/
|
|
9778
|
+
baseUrl?: string;
|
|
9754
9779
|
};
|
|
9755
9780
|
/** A loaded font subset, ready to hand to a renderer's `fonts`. */
|
|
9756
9781
|
type FontSubset = {
|
|
@@ -2818,6 +2818,11 @@ interface GoogleFontCatalog {
|
|
|
2818
2818
|
style: "italic" | "normal";
|
|
2819
2819
|
axis: never;
|
|
2820
2820
|
};
|
|
2821
|
+
"Geist Pixel": {
|
|
2822
|
+
weight: 400;
|
|
2823
|
+
style: "normal";
|
|
2824
|
+
axis: "ELSH";
|
|
2825
|
+
};
|
|
2821
2826
|
"Gelasio": {
|
|
2822
2827
|
weight: 400 | 500 | 600 | 700;
|
|
2823
2828
|
style: "italic" | "normal";
|
|
@@ -4938,6 +4943,11 @@ interface GoogleFontCatalog {
|
|
|
4938
4943
|
style: "normal";
|
|
4939
4944
|
axis: never;
|
|
4940
4945
|
};
|
|
4946
|
+
"Montenegrin Gothic One": {
|
|
4947
|
+
weight: 400;
|
|
4948
|
+
style: "normal";
|
|
4949
|
+
axis: never;
|
|
4950
|
+
};
|
|
4941
4951
|
"Montez": {
|
|
4942
4952
|
weight: 400;
|
|
4943
4953
|
style: "normal";
|
|
@@ -9578,6 +9588,16 @@ interface GoogleFontCatalog {
|
|
|
9578
9588
|
style: "normal";
|
|
9579
9589
|
axis: never;
|
|
9580
9590
|
};
|
|
9591
|
+
"Yuyu": {
|
|
9592
|
+
weight: 400;
|
|
9593
|
+
style: "normal";
|
|
9594
|
+
axis: never;
|
|
9595
|
+
};
|
|
9596
|
+
"Yuyu Short": {
|
|
9597
|
+
weight: 400;
|
|
9598
|
+
style: "normal";
|
|
9599
|
+
axis: never;
|
|
9600
|
+
};
|
|
9581
9601
|
"ZCOOL KuaiLe": {
|
|
9582
9602
|
weight: 400;
|
|
9583
9603
|
style: "normal";
|
|
@@ -9751,6 +9771,11 @@ type GoogleFontsOptions = FetchOptions & {
|
|
|
9751
9771
|
* playground re-rendering on each edit) so the metadata is fetched and parsed once.
|
|
9752
9772
|
*/
|
|
9753
9773
|
cache?: Pick<Map<string, string>, "has" | "get" | "set">;
|
|
9774
|
+
/**
|
|
9775
|
+
* css2 base URL. Defaults to Google Fonts; point it at an API-compatible mirror like
|
|
9776
|
+
* `https://fonts.bunny.net/css2`.
|
|
9777
|
+
*/
|
|
9778
|
+
baseUrl?: string;
|
|
9754
9779
|
};
|
|
9755
9780
|
/** A loaded font subset, ready to hand to a renderer's `fonts`. */
|
|
9756
9781
|
type FontSubset = {
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.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,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 c(e){let t=new URL(
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./helpers-4kGcvc-Q.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,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 c(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`,s(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`,s(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function l(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())}async function u(e,t){let n=t.cache?.get(e);if(n!==void 0)return n;let r=await l(e,t);return t.cache?.set(e,r),r}const d=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function f(e,t){let n=`${e.family} ${e.subset}`,r=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:n,subsetOf:e.family,key:`${n}:${e.weight??``}:${e.style??``}:${r}`,weight:e.weight,style:e.style,ranges:e.ranges,data:()=>a(e.url,t).then(e=>e.arrayBuffer())}}function p(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 m(e){let t=[],n=0;for(let r of e.matchAll(d)){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?p(o):[]}),n+=1}return t}function h(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 g(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 _(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 v({fonts:e,source:t}){let n=g(t);return e.filter(e=>_(e.ranges??[],n))}function y(e){return{key:e,data:()=>a(e).then(e=>e.arrayBuffer())}}function b({fonts:e,source:t,subset:n}){return e&&n!==!1?v({fonts:e,source:t}):e}async function x(e){return e.families.length===0?[]:h(m(await u(c(e),e))).map(t=>f(t,e))}exports.collectCodepoints=g,exports.container=e.t,exports.em=e.n,exports.extractResourceUrls=i,exports.fetchOk=a,exports.fetchResources=o,exports.fontFromUrl=y,exports.fr=e.r,exports.googleFonts=x,exports.image=e.i,exports.percentage=e.a,exports.pickFonts=b,exports.rem=e.o,exports.rgba=e.s,exports.style=e.c,exports.subsetFonts=v,exports.text=e.l,exports.vh=e.u,exports.vw=e.d;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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 extractResourceUrls, S as FetchResourcesOptions, T as fetchResources, _ as googleFonts, a as percentage, b as FetchLike, 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 pickFonts, w as fetchOk, x as FetchOptions, y as subsetFonts } from "./index-
|
|
2
|
+
import { C as extractResourceUrls, S as FetchResourcesOptions, T as fetchResources, _ as googleFonts, a as percentage, b as FetchLike, 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 pickFonts, w as fetchOk, x as FetchOptions, y as subsetFonts } from "./index-DoixwISc.cjs";
|
|
3
3
|
export { ContainerNode, FetchLike, FetchOptions, FetchResourcesOptions, FontSubset, GoogleFontFamily, GoogleFontsOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextFit, TextNode, collectCodepoints, container, em, extractResourceUrls, fetchOk, fetchResources, fontFromUrl, fr, googleFonts, image, percentage, pickFonts, rem, rgba, style, subsetFonts, text, vh, vw };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
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 extractResourceUrls, S as FetchResourcesOptions, T as fetchResources, _ as googleFonts, a as percentage, b as FetchLike, 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 pickFonts, w as fetchOk, x as FetchOptions, y as subsetFonts } from "./index-
|
|
2
|
+
import { C as extractResourceUrls, S as FetchResourcesOptions, T as fetchResources, _ as googleFonts, a as percentage, b as FetchLike, 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 pickFonts, w as fetchOk, x as FetchOptions, y as subsetFonts } from "./index-B1e5HbDk.mjs";
|
|
3
3
|
export { ContainerNode, FetchLike, FetchOptions, FetchResourcesOptions, FontSubset, GoogleFontFamily, GoogleFontsOptions, ImageNode, Node, NodeAttributes, NodeMetadata, ReactElementLike, TextFit, TextNode, collectCodepoints, container, em, extractResourceUrls, fetchOk, fetchResources, fontFromUrl, fr, googleFonts, image, percentage, pickFonts, rem, rgba, style, subsetFonts, 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-CVQCT1Rh.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,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 v(e){let t=new URL(
|
|
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-CVQCT1Rh.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,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 v(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`,_(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`,_(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function y(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())}async function b(e,t){let n=t.cache?.get(e);if(n!==void 0)return n;let r=await y(e,t);return t.cache?.set(e,r),r}const x=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function S(e,t){let n=`${e.family} ${e.subset}`,r=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:n,subsetOf:e.family,key:`${n}:${e.weight??``}:${e.style??``}:${r}`,weight:e.weight,style:e.style,ranges:e.ranges,data:()=>h(e.url,t).then(e=>e.arrayBuffer())}}function C(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 w(e){let t=[],n=0;for(let r of e.matchAll(x)){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?C(o):[]}),n+=1}return t}function T(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(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 D(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 O({fonts:e,source:t}){let n=E(t);return e.filter(e=>D(e.ranges??[],n))}function k(e){return{key:e,data:()=>h(e).then(e=>e.arrayBuffer())}}function A({fonts:e,source:t,subset:n}){return e&&n!==!1?O({fonts:e,source:t}):e}async function j(e){return e.families.length===0?[]:T(w(await b(v(e),e))).map(t=>S(t,e))}export{E as collectCodepoints,l as container,a as em,m as extractResourceUrls,h as fetchOk,g as fetchResources,k as fontFromUrl,s as fr,j as googleFonts,r as image,e as percentage,A as pickFonts,o as rem,c as rgba,t as style,O as subsetFonts,i as text,u as vh,n as vw};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/helpers",
|
|
3
|
-
"version": "2.0.0-rc.
|
|
3
|
+
"version": "2.0.0-rc.3",
|
|
4
4
|
"description": "Utility helpers for converting JSX/HTML to Takumi node trees and handling resources.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@types/bun": "^1.3.14",
|
|
89
89
|
"@types/react": "19.2.17",
|
|
90
90
|
"@types/react-dom": "^19.2.3",
|
|
91
|
-
"lucide-react": "^1.
|
|
91
|
+
"lucide-react": "^1.22.0",
|
|
92
92
|
"react": "^19.2.7",
|
|
93
93
|
"react-dom": "^19.2.7",
|
|
94
94
|
"tsdown": "^0.22.3",
|