@takumi-rs/helpers 0.28.4 → 0.28.5
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/jsx/jsx.cjs +1 -1
- package/dist/jsx/jsx.d.cts +6 -2
- package/dist/jsx/jsx.d.ts +6 -2
- package/dist/jsx/jsx.js +1 -1
- package/package.json +1 -1
package/dist/jsx/jsx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var v=Object.prototype.hasOwnProperty;var A=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},$=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of L(e))!v.call(t,i)&&i!==r&&p(t,i,{get:()=>e[i],enumerable:!(o=C(e,i))||o.enumerable});return t};var O=t=>$(p({},"__esModule",{value:!0}),t);var V={};A(V,{fromJsx:()=>J});module.exports=O(V);function f(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t){let e={type:"container",children:t.children};return f(e,t.style),e}function h(t,e){let r={type:"text",text:t};return f(r,e),r}function l(t){let e={type:"image",src:t.src};return f(e,t.style),e}function u(t){return{percentage:t}}function n(t){return{em:t}}function k(t,e,r,o=1){return[t,e,r,o]}var m={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:k(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};function y(t,e){return t.type===e}function R(t){return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"}function S(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function T(t){return typeof t=="string"||typeof t=="number"}function b(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function j(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var z=["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"];function I(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":z.includes(t)?r=S(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let o=j(e);if(o)return`style="${b(o)}"`}return`${r}="${b(String(e))}"`}function F(t){return Object.entries(t).map(([e,r])=>I(e,r)).filter(e=>e!==void 0)}var W=(t,e)=>{let r=t.props||{},o=F(r),i=r.children,d=Array.isArray(i)?i.map(N=>e(N)).join(""):e(i);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${d}</${t.type}>`},c=t=>t==null||t===!1?"":T(t)?String(t):Array.isArray(t)?t.map(c).join(""):R(t)?W(t,c):"";function P(t){let e=t.props||{};if(!("xmlns"in e)){let r={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return c(r)||""}return c(t)||""}var M=Symbol.for("react.forward_ref"),X=Symbol.for("react.memo");function H(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"type"in t}async function J(t){let e=await s(t);return e.length===0?a({}):e.length===1&&e[0]!==void 0?e[0]:a({children:e,style:{width:u(100),height:u(100)}})}async function s(t){if(t==null)return[];if(t instanceof Promise)return s(await t);if(typeof t=="object"&&Symbol.iterator in t)return B(t);if(H(t)){let e=await x(t);return Array.isArray(e)?e:e?[e]:[]}return[h(String(t))]}function w(t){return typeof t=="function"}function _(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===M&&e.render)return s(e.render(t.props,null))}function K(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==X)return;let r=e.type;if(w(r))return s(r(t.props));let o={...t,type:r};return x(o)}async function x(t){if(w(t.type))return s(t.type(t.props));let e=_(t);if(e!==void 0)return e;let r=K(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await E(t)||[];if(y(t,"img"))return[D(t)];if(y(t,"svg"))return[Y(t)];let o=await E(t),i=g(t.props);return typeof t.type=="string"&&t.type in m&&Object.assign(i,m[t.type]),[a({children:o,style:i})]}function D(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=g(t.props);return l({src:t.props.src,style:e})}function Y(t){let e=g(t.props),r=P(t);return l({src:r,style:e})}function g(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function E(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):s(t.props.children)}async function B(t){return(await Promise.all(Array.from(t).map(s))).flat()}0&&(module.exports={fromJsx});
|
package/dist/jsx/jsx.d.cts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { N as Node } from '../types-8M7fRh4t.cjs';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type ReactElementLike<K extends string = string, P = unknown> = {
|
|
5
|
+
type: K;
|
|
6
|
+
props: P;
|
|
7
|
+
};
|
|
8
|
+
declare function fromJsx(element: ReactNode | ReactElementLike): Promise<Node>;
|
|
5
9
|
|
|
6
|
-
export { fromJsx };
|
|
10
|
+
export { type ReactElementLike, fromJsx };
|
package/dist/jsx/jsx.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { N as Node } from '../types-8M7fRh4t.js';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type ReactElementLike<K extends string = string, P = unknown> = {
|
|
5
|
+
type: K;
|
|
6
|
+
props: P;
|
|
7
|
+
};
|
|
8
|
+
declare function fromJsx(element: ReactNode | ReactElementLike): Promise<Node>;
|
|
5
9
|
|
|
6
|
-
export { fromJsx };
|
|
10
|
+
export { type ReactElementLike, fromJsx };
|
package/dist/jsx/jsx.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function
|
|
1
|
+
function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t){let e={type:"container",children:t.children};return p(e,t.style),e}function d(t,e){let r={type:"text",text:t};return p(r,e),r}function f(t){let e={type:"image",src:t.src};return p(e,t.style),e}function l(t){return{percentage:t}}function n(t){return{em:t}}function h(t,e,r,o=1){return[t,e,r,o]}var u={p:{margin:[n(1),0]},blockquote:{margin:[n(1),40]},center:{textAlign:"center"},hr:{margin:[n(.5),"auto"],borderWidth:1},h1:{fontSize:n(2),margin:[n(.67),0],fontWeight:700},h2:{fontSize:n(1.5),margin:[n(.83),0],fontWeight:700},h3:{fontSize:n(1.17),margin:[n(1),0],fontWeight:700},h4:{margin:[n(1.33),0],fontWeight:700},h5:{fontSize:n(.83),margin:[n(1.67),0],fontWeight:700},h6:{fontSize:n(.67),margin:[n(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[n(1),0]},mark:{backgroundColor:h(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};function m(t,e){return t.type===e}function k(t){return typeof t=="object"&&t!==null&&"type"in t&&typeof t.type=="string"}function R(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function N(t){return typeof t=="string"||typeof t=="number"}function S(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}function C(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var L=["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"];function v(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":L.includes(t)?r=R(t):r=t,typeof e=="boolean")return`${r}="${String(e)}"`;if(t==="style"&&typeof e=="object"){let o=C(e);if(o)return`style="${S(o)}"`}return`${r}="${S(String(e))}"`}function A(t){return Object.entries(t).map(([e,r])=>v(e,r)).filter(e=>e!==void 0)}var $=(t,e)=>{let r=t.props||{},o=A(r),s=r.children,g=Array.isArray(s)?s.map(x=>e(x)).join(""):e(s);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${g}</${t.type}>`},c=t=>t==null||t===!1?"":N(t)?String(t):Array.isArray(t)?t.map(c).join(""):k(t)?$(t,c):"";function b(t){let e=t.props||{};if(!("xmlns"in e)){let r={...t,props:{...e,xmlns:"http://www.w3.org/2000/svg"}};return c(r)||""}return c(t)||""}var O=Symbol.for("react.forward_ref"),T=Symbol.for("react.memo");function j(t){return(typeof t=="object"||typeof t=="function")&&t!==null&&"type"in t}async function Z(t){let e=await i(t);return e.length===0?a({}):e.length===1&&e[0]!==void 0?e[0]:a({children:e,style:{width:l(100),height:l(100)}})}async function i(t){if(t==null)return[];if(t instanceof Promise)return i(await t);if(typeof t=="object"&&Symbol.iterator in t)return M(t);if(j(t)){let e=await w(t);return Array.isArray(e)?e:e?[e]:[]}return[d(String(t))]}function E(t){return typeof t=="function"}function z(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===O&&e.render)return i(e.render(t.props,null))}function I(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==T)return;let r=e.type;if(E(r))return i(r(t.props));let o={...t,type:r};return w(o)}async function w(t){if(E(t.type))return i(t.type(t.props));let e=z(t);if(e!==void 0)return e;let r=I(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await P(t)||[];if(m(t,"img"))return[F(t)];if(m(t,"svg"))return[W(t)];let o=await P(t),s=y(t.props);return typeof t.type=="string"&&t.type in u&&Object.assign(s,u[t.type]),[a({children:o,style:s})]}function F(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=y(t.props);return f({src:t.props.src,style:e})}function W(t){let e=y(t.props),r=b(t);return f({src:r,style:e})}function y(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function P(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):i(t.props.children)}async function M(t){return(await Promise.all(Array.from(t).map(i))).flat()}export{Z as fromJsx};
|