@takumi-rs/helpers 0.62.7 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var c=Object.defineProperty;var
|
|
1
|
+
"use strict";var c=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var w=(t,e)=>{for(var r in e)c(t,r,{get:e[r],enumerable:!0})},h=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of d(e))!y.call(t,i)&&i!==r&&c(t,i,{get:()=>e[i],enumerable:!(n=l(e,i))||n.enumerable});return t};var p=t=>h(c({},"__esModule",{value:!0}),t);var I={};w(I,{container:()=>g,em:()=>O,fetchResources:()=>A,fr:()=>R,image:()=>b,percentage:()=>T,rem:()=>C,rgba:()=>v,style:()=>S,text:()=>N,vh:()=>P,vw:()=>$});module.exports=p(I);function u(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t,e){e&&Object.keys(e).length>0&&(t.preset=e)}function g(t){let e={type:"container",children:t.children};return t.tw&&(e.tw=t.tw),a(e,t.preset),u(e,t.style),e}function N(t,e){if(typeof t=="string"){let n={type:"text",text:t};return u(n,e),n}let r={type:"text",text:t.text};return t.tw&&(r.tw=t.tw),a(r,t.preset),u(r,e??t.style),r}function b(t){let e={type:"image",src:t.src,width:t.width,height:t.height};return t.tw&&(e.tw=t.tw),a(e,t.preset),u(e,t.style),e}function S(t){return t}function T(t){return`${t}%`}function $(t){return`${t}vw`}function P(t){return`${t}vh`}function O(t){return`${t}em`}function C(t){return`${t}rem`}function R(t){return`${t}fr`}function v(t,e,r,n=1){return`rgb(${t} ${e} ${r} / ${n})`}async function A(t,e){let r=AbortSignal.timeout(e?.timeout??5e3),n=e?.fetch??globalThis.fetch,i=e?.throwOnError??!0,f=[...new Set(t)].map(async o=>{let s=await n(o,{signal:r});if(!s.ok)throw new Error(`HTTP ${s.status}: ${s.statusText} for ${o}`);let x=await s.arrayBuffer();return[o,x]});if(i){let o=await Promise.all(f);return new Map(o)}let m=(await Promise.allSettled(f)).filter(o=>o.status==="fulfilled").map(o=>o.value);return new Map(m)}0&&(module.exports={container,em,fetchResources,fr,image,percentage,rem,rgba,style,text,vh,vw});
|
package/dist/index.d.cts
CHANGED
|
@@ -15,4 +15,31 @@ declare function rem(rem: number): `${number}rem`;
|
|
|
15
15
|
declare function fr(fr: number): `${number}fr`;
|
|
16
16
|
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
type FetchResourcesOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Timeout in milliseconds.
|
|
21
|
+
* @default 5000
|
|
22
|
+
*/
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Custom fetch function.
|
|
26
|
+
* @default {globalThis.fetch}
|
|
27
|
+
*/
|
|
28
|
+
fetch?: (input: string, init?: RequestInit) => Promise<Response>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to throw on any fetch failure. If false, returns only successful fetches.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
throwOnError?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Fetches multiple resources concurrently and returns them as a Map.
|
|
37
|
+
* Validates HTTP status codes and automatically deduplicates URLs.
|
|
38
|
+
*
|
|
39
|
+
* @param urls - URLs to fetch
|
|
40
|
+
* @param options - Fetch options
|
|
41
|
+
* @returns Map of URL to ArrayBuffer
|
|
42
|
+
*/
|
|
43
|
+
declare function fetchResources(urls: string[], options?: FetchResourcesOptions): Promise<Map<string, ArrayBuffer>>;
|
|
44
|
+
|
|
45
|
+
export { ContainerNode, type FetchResourcesOptions, ImageNode, TextNode, container, em, fetchResources, fr, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.d.ts
CHANGED
|
@@ -15,4 +15,31 @@ declare function rem(rem: number): `${number}rem`;
|
|
|
15
15
|
declare function fr(fr: number): `${number}fr`;
|
|
16
16
|
declare function rgba(r: number, g: number, b: number, a?: number): `rgb(${number} ${number} ${number} / ${number})`;
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
type FetchResourcesOptions = {
|
|
19
|
+
/**
|
|
20
|
+
* Timeout in milliseconds.
|
|
21
|
+
* @default 5000
|
|
22
|
+
*/
|
|
23
|
+
timeout?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Custom fetch function.
|
|
26
|
+
* @default {globalThis.fetch}
|
|
27
|
+
*/
|
|
28
|
+
fetch?: (input: string, init?: RequestInit) => Promise<Response>;
|
|
29
|
+
/**
|
|
30
|
+
* Whether to throw on any fetch failure. If false, returns only successful fetches.
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
throwOnError?: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Fetches multiple resources concurrently and returns them as a Map.
|
|
37
|
+
* Validates HTTP status codes and automatically deduplicates URLs.
|
|
38
|
+
*
|
|
39
|
+
* @param urls - URLs to fetch
|
|
40
|
+
* @param options - Fetch options
|
|
41
|
+
* @returns Map of URL to ArrayBuffer
|
|
42
|
+
*/
|
|
43
|
+
declare function fetchResources(urls: string[], options?: FetchResourcesOptions): Promise<Map<string, ArrayBuffer>>;
|
|
44
|
+
|
|
45
|
+
export { ContainerNode, type FetchResourcesOptions, ImageNode, TextNode, container, em, fetchResources, fr, image, percentage, rem, rgba, style, text, vh, vw };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function s(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function u(t,e){e&&Object.keys(e).length>0&&(t.preset=e)}function d(t){let e={type:"container",children:t.children};return t.tw&&(e.tw=t.tw),u(e,t.preset),s(e,t.style),e}function y(t,e){if(typeof t=="string"){let o={type:"text",text:t};return s(o,e),o}let n={type:"text",text:t.text};return t.tw&&(n.tw=t.tw),u(n,t.preset),s(n,e??t.style),n}function w(t){let e={type:"image",src:t.src,width:t.width,height:t.height};return t.tw&&(e.tw=t.tw),u(e,t.preset),s(e,t.style),e}function h(t){return t}function p(t){return`${t}%`}function g(t){return`${t}vw`}function N(t){return`${t}vh`}function b(t){return`${t}em`}function S(t){return`${t}rem`}function T(t){return`${t}fr`}function $(t,e,n,o=1){return`rgb(${t} ${e} ${n} / ${o})`}async function O(t,e){let n=AbortSignal.timeout(e?.timeout??5e3),o=e?.fetch??globalThis.fetch,a=e?.throwOnError??!0,c=[...new Set(t)].map(async r=>{let i=await o(r,{signal:n});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText} for ${r}`);let m=await i.arrayBuffer();return[r,m]});if(a){let r=await Promise.all(c);return new Map(r)}let f=(await Promise.allSettled(c)).filter(r=>r.status==="fulfilled").map(r=>r.value);return new Map(f)}export{d as container,b as em,O as fetchResources,T as fr,w as image,p as percentage,S as rem,$ as rgba,h as style,y as text,N as vh,g as vw};
|