@takumi-rs/helpers 2.5.7 → 2.5.8
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/{fonts-BDH-QGS3.d.cts → fonts-BFt44wX3.d.cts} +1 -1
- package/dist/{fonts-DI_b5zLT.cjs → fonts-BT1cVqWh.cjs} +1 -1
- package/dist/{fonts-BXhtO--P.mjs → fonts-VUK5hilE.mjs} +1 -1
- package/dist/{fonts-UnPqxrF6.d.mts → fonts-aYq5UMvm.d.mts} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/renderer.cjs +1 -1
- package/dist/renderer.d.cts +1 -1
- package/dist/renderer.d.mts +1 -1
- package/dist/renderer.mjs +1 -1
- package/package.json +1 -1
|
@@ -923,7 +923,7 @@ type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
|
923
923
|
type FetchOptions = {
|
|
924
924
|
/** Custom fetch implementation. @default globalThis.fetch */
|
|
925
925
|
fetch?: FetchLike;
|
|
926
|
-
/** Abort the request after this many milliseconds; `0` or negative disables it. @default
|
|
926
|
+
/** Abort the request after this many milliseconds; `0` or negative disables it. @default 30000 */
|
|
927
927
|
timeout?: number;
|
|
928
928
|
/** Caller abort signal, combined with the timeout. */
|
|
929
929
|
signal?: AbortSignal;
|
|
@@ -1 +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 r=t.fetch??globalThis.fetch,i=t.timeout??
|
|
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 r=t.fetch??globalThis.fetch,i=t.timeout??3e4,a=i<=0?void 0:AbortSignal.timeout(i),o=[t.signal,t.init?.signal,a].filter(e=>e!==void 0),s=o.length?AbortSignal.any(o):void 0,c={...t.init,signal:s},l=t.allowUrl?await n(e,t.allowUrl,r,c):await r(e,c);if(!l.ok)throw Error(`HTTP ${l.status} ${l.statusText} fetching ${e}`);return l}async function n(e,t,n,r){let i=e;for(let e=0;e<5;e++){let e=await n(i,{...r,redirect:`manual`}),a=e.headers.get(`location`);if(e.status<300||e.status>=400||!a)return e;if(await e.body?.cancel().catch(()=>{}),i=new URL(a,i).toString(),!t(i))throw Error(`URL blocked by allowUrl policy: ${i}`)}throw Error(`Too many redirects fetching ${e}`)}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(t,n){if(typeof t==`string`)for(let r of t.matchAll(e)){let e=r[2]?.trim();e&&i(e)&&n.add(e)}else if(Array.isArray(t))for(let e of t)a(e,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,n,i){let a=i?.get(e);if(a)return a;let o=t(e,n).then(e=>r(e,n.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,n){return t(e,{...n,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,n.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,n,i){let a=`${e.family} ${e.subset}`,o=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:a,subsetOf:e.family,key:`${a}:${e.weight??``}:${e.style??``}:${o}:${i??``}`,weight:e.weight,style:e.style,ranges:e.ranges,generic:i,data:()=>t(e.url,n).then(e=>r(e,n.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,n={}){return{key:e,data:()=>t(e,n).then(e=>r(e,n.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])),r=new Map(e.families.flatMap(e=>typeof e==`string`||!e.generic?[]:[[e.name,e.generic]]));return v(_(t)).sort((e,t)=>(n.get(e.family)??0)-(n.get(t.family)??0)).map(t=>h(t,e,r.get(t.family)))}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return 33554432}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}});
|
|
@@ -1 +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,i=t.timeout??
|
|
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,i=t.timeout??3e4,a=i<=0?void 0:AbortSignal.timeout(i),o=[t.signal,t.init?.signal,a].filter(e=>e!==void 0),s=o.length?AbortSignal.any(o):void 0,c={...t.init,signal:s},l=t.allowUrl?await r(e,t.allowUrl,n,c):await n(e,c);if(!l.ok)throw Error(`HTTP ${l.status} ${l.statusText} fetching ${e}`);return l}async function r(e,t,n,r){let i=e;for(let e=0;e<5;e++){let e=await n(i,{...r,redirect:`manual`}),a=e.headers.get(`location`);if(e.status<300||e.status>=400||!a)return e;if(await e.body?.cancel().catch(()=>{}),i=new URL(a,i).toString(),!t(i))throw Error(`URL blocked by allowUrl policy: ${i}`)}throw Error(`Too many redirects fetching ${e}`)}async function i(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 a(e){return e.startsWith(`https://`)||e.startsWith(`http://`)}function o(e,n){if(typeof e==`string`)for(let r of e.matchAll(t)){let e=r[2]?.trim();e&&a(e)&&n.add(e)}else if(Array.isArray(e))for(let t of e)o(t,n)}function s(e){let t=new Set,n=e=>{let r=e=>{e&&(o(e.backgroundImage,t),o(e.maskImage,t))};if(r(e.style),r(e.preset),o(e.tw,t),e.type===`image`){typeof e.src==`string`&&a(e.src)&&t.add(e.src);return}if(e.type===`container`)for(let t of e.children??[])n(t)};return n(e),[...t]}function c(e,t,r){let a=r?.get(e);if(a)return a;let o=n(e,t).then(e=>i(e,t.maxBytes??33554432)).catch(t=>{throw r?.delete(e),t});return r?.set(e,o),o}async function l({node:e,sources:t=[],fetchCache:n,fetch:r,timeout:i,signal:a,maxBytes:o,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(s))].filter(e=>!f.has(e)),m={fetch:r,timeout:i,signal:a,maxBytes:o,allowUrl:l},h=p.map(async e=>({src:e,data:await c(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 u=new Map;function d(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 f(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`,d(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`,d(n.name,r,a,o))}return e.display&&t.searchParams.set(`display`,e.display),t.toString()}function p(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=>i(e,t.maxBytes??2097152)).then(e=>new TextDecoder().decode(e))}function m(e,t){let n=t.cache??u,r=n.get(e);if(r)return r;let i=p(e,t);return n.set(e,i),i.catch(()=>n.delete(e)),i}const h=/(?:\/\*\s*([^*]+?)\s*\*\/\s*)?@font-face\s*\{([^}]*)\}/g;function g(e,t,r){let a=`${e.family} ${e.subset}`,o=e.ranges.map(([e,t])=>`${e}-${t}`).join(`,`);return{name:a,subsetOf:e.family,key:`${a}:${e.weight??``}:${e.style??``}:${o}:${r??``}`,weight:e.weight,style:e.style,ranges:e.ranges,generic:r,data:()=>n(e.url,t).then(e=>i(e,t.maxBytes??33554432))}}function _(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 v(e){let t=[],n=0;for(let r of e.matchAll(h)){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?_(o):[]}),n+=1}return t}function y(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 b(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 x(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 S({fonts:e,source:t}){let n=b(t);return e.filter(e=>x(e.ranges??[],n))}function C(e,t={}){return{key:e,data:()=>n(e,t).then(e=>i(e,t.maxBytes??33554432))}}async function w(e){if(Array.isArray(e)&&(e={families:e}),e.families.length===0)return[];let t=await m(f(e),e),n=new Map(e.families.map((e,t)=>[typeof e==`string`?e:e.name,t])),r=new Map(e.families.flatMap(e=>typeof e==`string`||!e.generic?[]:[[e.name,e.generic]]));return y(v(t)).sort((e,t)=>(n.get(e.family)??0)-(n.get(t.family)??0)).map(t=>g(t,e,r.get(t.family)))}export{e as a,i as c,S as i,C as n,n as o,w as r,l as s,b as t};
|
|
@@ -923,7 +923,7 @@ type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
|
923
923
|
type FetchOptions = {
|
|
924
924
|
/** Custom fetch implementation. @default globalThis.fetch */
|
|
925
925
|
fetch?: FetchLike;
|
|
926
|
-
/** Abort the request after this many milliseconds; `0` or negative disables it. @default
|
|
926
|
+
/** Abort the request after this many milliseconds; `0` or negative disables it. @default 30000 */
|
|
927
927
|
timeout?: number;
|
|
928
928
|
/** Caller abort signal, combined with the timeout. */
|
|
929
929
|
signal?: AbortSignal;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-BT1cVqWh.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,5 +1,5 @@
|
|
|
1
1
|
import { a as NodeMetadata, c as TextFit, i as NodeAttributes, l as TextNode, n as ImageNode, o as ReactElementLike, r as Node, s as RgbaImage, t as ContainerNode } from "./types-Bfi8SERZ.cjs";
|
|
2
|
-
import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-
|
|
2
|
+
import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-BFt44wX3.cjs";
|
|
3
3
|
import { CSSProperties } from "react";
|
|
4
4
|
//#region src/helpers.d.ts
|
|
5
5
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as NodeMetadata, c as TextFit, i as NodeAttributes, l as TextNode, n as ImageNode, o as ReactElementLike, r as Node, s as RgbaImage, t as ContainerNode } from "./types-Bfi8SERZ.mjs";
|
|
2
|
-
import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-
|
|
2
|
+
import { _ as readBodyLimited, a as collectCodepoints, c as subsetFonts, d as FetchedImage, f as ImageFetchCache, g as prepareImages, h as fetchOk, i as GoogleFontsOptions, l as FetchLike, m as defaultMaxFetchBytes, n as GenericFontFamily, o as fontFromUrl, p as PrepareImagesOptions, r as GoogleFontFamily, s as googleFonts, t as FontSubset, u as FetchOptions } from "./fonts-aYq5UMvm.mjs";
|
|
3
3
|
import { CSSProperties } from "react";
|
|
4
4
|
//#region src/helpers.d.ts
|
|
5
5
|
declare function container(props: Omit<ContainerNode, "type">): ContainerNode;
|
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-
|
|
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-VUK5hilE.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/renderer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./fonts-BT1cVqWh.cjs");function t(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function n(e){return e instanceof ArrayBuffer?new Uint8Array(e):e}function r(e){return t(e)?e:typeof e.data==`function`?e.data():e.data}function i(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 a(e){let{sources:t=[],cache:r}=Array.isArray(e)?{sources:e}:e,i=new Map;for(let e of t)i.set(e.src,e);return Promise.all([...i.values()].map(async({src:e,data:t,cache:i})=>({src:e,data:n(typeof t==`function`?await t():t),cache:i??r})))}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(a){let o=typeof a==`string`?e.n(a):a,s=i(o),c=this.getFont(s);if(c)return c;let l=r(o),u=Promise.resolve(l).then(e=>{let r=n(e);return this.registerInner(t(o)?r:{...o,data:r})}).catch(e=>{throw this.deleteFont(s),e});return this.setFont(s,u),u}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.i({fonts:l,source:r}),s,a);return o?.throwIfAborted(),{options:{...c,...u},signal:o}}exports.FontRegistry=o,exports.prepareRenderInput=s,exports.resolveImageLoaders=a;
|
package/dist/renderer.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as Node } from "./types-Bfi8SERZ.cjs";
|
|
2
|
-
import { n as GenericFontFamily } from "./fonts-
|
|
2
|
+
import { n as GenericFontFamily } from "./fonts-BFt44wX3.cjs";
|
|
3
3
|
//#region src/renderer.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
|
package/dist/renderer.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as Node } from "./types-Bfi8SERZ.mjs";
|
|
2
|
-
import { n as GenericFontFamily } from "./fonts-
|
|
2
|
+
import { n as GenericFontFamily } from "./fonts-aYq5UMvm.mjs";
|
|
3
3
|
//#region src/renderer.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Shared wrapper primitives for the `@takumi-rs/core` (napi) and `@takumi-rs/wasm` renderer
|
package/dist/renderer.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t}from"./fonts-
|
|
1
|
+
import{i as e,n as t}from"./fonts-VUK5hilE.mjs";function n(e){return e instanceof Uint8Array||e instanceof ArrayBuffer||typeof Buffer<`u`&&Buffer.isBuffer(e)}function r(e){return e instanceof ArrayBuffer?new Uint8Array(e):e}function i(e){return n(e)?e:typeof e.data==`function`?e.data():e.data}function a(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 o(e){let{sources:t=[],cache:n}=Array.isArray(e)?{sources:e}:e,i=new Map;for(let e of t)i.set(e.src,e);return Promise.all([...i.values()].map(async({src:e,data:t,cache:i})=>({src:e,data:r(typeof t==`function`?await t():t),cache:i??n})))}var s=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 o=typeof e==`string`?t(e):e,s=a(o),c=this.getFont(s);if(c)return c;let l=i(o),u=Promise.resolve(l).then(e=>{let t=r(e);return this.registerInner(n(o)?t:{...o,data:t})}).catch(e=>{throw this.deleteFont(s),e});return this.setFont(s,u),u}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 o(t):void 0,fontFamilies:n??r}}};async function c(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{s as FontRegistry,c as prepareRenderInput,o as resolveImageLoaders};
|