@takumi-rs/helpers 0.28.0 → 0.28.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/jsx/jsx.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var s=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var N=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var r in e)s(t,r,{get:e[r],enumerable:!0})},k=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of N(e))!w.call(t,i)&&i!==r&&s(t,i,{get:()=>e[i],enumerable:!(o=R(e,i))||o.enumerable});return t};var C=t=>k(s({},"__esModule",{value:!0}),t);var M={};x(M,{fromJsx:()=>v});module.exports=C(M);var S=require("react"),h=require("react-dom/server");function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function c(t){let e={type:"container",children:t.children};return p(e,t.style),e}function m(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 u(t){return{percentage:t}}function n(t){return{em:t}}function d(t,e,r,o=1){return[t,e,r,o]}var y={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:d(255,255,0),color:0},big:{fontSize:n(1.2)},small:{fontSize:n(1/1.2)}};var T=Symbol.for("react.transitional.element"),A=Symbol.for("react.element"),I=Symbol.for("react.forward_ref"),$=Symbol.for("react.memo");function _(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===T||t.$$typeof===A)}async function v(t){let e=await a(t);return e.length===0?c({}):e.length===1&&e[0]!==void 0?e[0]:c({children:e,style:{width:u(100),height:u(100)}})}async function a(t){if(t==null)return[];if(t instanceof Promise)return a(await t);if(typeof t=="object"&&Symbol.iterator in t)return L(t);if(_(t)){let e=await P(t);return Array.isArray(e)?e:e?[e]:[]}return[m(String(t))]}function b(t){return typeof t=="function"}function F(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===I&&e.render)return a(e.render(t.props,null))}function W(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==$)return;let r=e.type;if(b(r))return a(r(t.props));let o={...t,type:r};return P(o)}async function P(t){if(b(t.type))return a(t.type(t.props));let e=F(t);if(e!==void 0)return e;let r=W(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await E(t)||[];if(g(t,"img"))return[O(t)];if(g(t,"svg"))return[j(t)];let o=await E(t),i=l(t.props);return typeof t.type=="string"&&t.type in y&&Object.assign(i,y[t.type]),[c({children:o,style:i})]}function O(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=l(t.props);return f({src:t.props.src,style:e})}function j(t){let e=l(t.props),r=(0,h.renderToStaticMarkup)((0,S.cloneElement)(t,{xmlns:"http://www.w3.org/2000/svg",...t.props},t.props.children));return f({src:r,style:e})}function l(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function g(t,e){return t.type===e}function E(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):a(t.props.children)}async function L(t){return(await Promise.all(Array.from(t).map(a))).flat()}0&&(module.exports={fromJsx});
1
+ "use strict";var p=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var $=(t,e)=>{for(var r in e)p(t,r,{get:e[r],enumerable:!0})},v=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of A(e))!T.call(t,i)&&i!==r&&p(t,i,{get:()=>e[i],enumerable:!(o=C(e,i))||o.enumerable});return t};var O=t=>v(p({},"__esModule",{value:!0}),t);var Z={};$(Z,{fromJsx:()=>Y});module.exports=O(Z);function l(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function s(t){let e={type:"container",children:t.children};return l(e,t.style),e}function h(t,e){let r={type:"text",text:t};return l(r,e),r}function f(t){let e={type:"image",src:t.src};return l(e,t.style),e}function u(t){return{percentage:t}}function n(t){return{em:t}}function S(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:S(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 E(t){return t.replace(/([A-Z])/g,"-$1").toLowerCase()}function I(t){return typeof t=="string"||typeof t=="number"}function b(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}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 F(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":z.includes(t)?r=E(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 L(t){return Object.entries(t).map(([e,r])=>F(e,r)).filter(e=>e!==void 0)}var W=(t,e)=>{let r=t.props||{},o=L(r),i=r.children,d=Array.isArray(i)?i.map(x=>e(x)).join(""):e(i);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${d}</${t.type}>`},c=t=>t==null||t===!1?"":I(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 _=Symbol.for("react.transitional.element"),M=Symbol.for("react.element"),X=Symbol.for("react.forward_ref"),H=Symbol.for("react.memo");function J(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===_||t.$$typeof===M)}async function Y(t){let e=await a(t);return e.length===0?s({}):e.length===1&&e[0]!==void 0?e[0]:s({children:e,style:{width:u(100),height:u(100)}})}async function a(t){if(t==null)return[];if(t instanceof Promise)return a(await t);if(typeof t=="object"&&Symbol.iterator in t)return q(t);if(J(t)){let e=await N(t);return Array.isArray(e)?e:e?[e]:[]}return[h(String(t))]}function k(t){return typeof t=="function"}function D(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===X&&e.render)return a(e.render(t.props,null))}function B(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==H)return;let r=e.type;if(k(r))return a(r(t.props));let o={...t,type:r};return N(o)}async function N(t){if(k(t.type))return a(t.type(t.props));let e=D(t);if(e!==void 0)return e;let r=B(t);if(r!==void 0)return r;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await w(t)||[];if(y(t,"img"))return[K(t)];if(y(t,"svg"))return[V(t)];let o=await w(t),i=g(t.props);return typeof t.type=="string"&&t.type in m&&Object.assign(i,m[t.type]),[s({children:o,style:i})]}function K(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=g(t.props);return f({src:t.props.src,style:e})}function V(t){let e=g(t.props),r=P(t);return f({src:r,style:e})}function g(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function w(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):a(t.props.children)}async function q(t){return(await Promise.all(Array.from(t).map(a))).flat()}0&&(module.exports={fromJsx});
package/dist/jsx/jsx.js CHANGED
@@ -1 +1 @@
1
- import{cloneElement as h}from"react";import{renderToStaticMarkup as b}from"react-dom/server";function c(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function a(t){let e={type:"container",children:t.children};return c(e,t.style),e}function l(t,e){let n={type:"text",text:t};return c(n,e),n}function s(t){let e={type:"image",src:t.src};return c(e,t.style),e}function p(t){return{percentage:t}}function r(t){return{em:t}}function m(t,e,n,i=1){return[t,e,n,i]}var f={p:{margin:[r(1),0]},blockquote:{margin:[r(1),40]},center:{textAlign:"center"},hr:{margin:[r(.5),"auto"],borderWidth:1},h1:{fontSize:r(2),margin:[r(.67),0],fontWeight:700},h2:{fontSize:r(1.5),margin:[r(.83),0],fontWeight:700},h3:{fontSize:r(1.17),margin:[r(1),0],fontWeight:700},h4:{margin:[r(1.33),0],fontWeight:700},h5:{fontSize:r(.83),margin:[r(1.67),0],fontWeight:700},h6:{fontSize:r(.67),margin:[r(2.33),0],fontWeight:700},strong:{fontWeight:700},b:{fontWeight:700},code:{fontFamily:"monospace"},kbd:{fontFamily:"monospace"},pre:{fontFamily:"monospace",margin:[r(1),0]},mark:{backgroundColor:m(255,255,0),color:0},big:{fontSize:r(1.2)},small:{fontSize:r(1/1.2)}};var P=Symbol.for("react.transitional.element"),R=Symbol.for("react.element"),N=Symbol.for("react.forward_ref"),w=Symbol.for("react.memo");function x(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===P||t.$$typeof===R)}async function M(t){let e=await o(t);return e.length===0?a({}):e.length===1&&e[0]!==void 0?e[0]:a({children:e,style:{width:p(100),height:p(100)}})}async function o(t){if(t==null)return[];if(t instanceof Promise)return o(await t);if(typeof t=="object"&&Symbol.iterator in t)return I(t);if(x(t)){let e=await S(t);return Array.isArray(e)?e:e?[e]:[]}return[l(String(t))]}function E(t){return typeof t=="function"}function k(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===N&&e.render)return o(e.render(t.props,null))}function C(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==w)return;let n=e.type;if(E(n))return o(n(t.props));let i={...t,type:n};return S(i)}async function S(t){if(E(t.type))return o(t.type(t.props));let e=k(t);if(e!==void 0)return e;let n=C(t);if(n!==void 0)return n;if(typeof t.type=="symbol"&&t.type===Symbol.for("react.fragment"))return await g(t)||[];if(d(t,"img"))return[T(t)];if(d(t,"svg"))return[A(t)];let i=await g(t),y=u(t.props);return typeof t.type=="string"&&t.type in f&&Object.assign(y,f[t.type]),[a({children:i,style:y})]}function T(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=u(t.props);return s({src:t.props.src,style:e})}function A(t){let e=u(t.props),n=b(h(t,{xmlns:"http://www.w3.org/2000/svg",...t.props},t.props.children));return s({src:n,style:e})}function u(t){return typeof t!="object"||t===null?{}:"style"in t&&typeof t.style=="object"?t.style:{}}function d(t,e){return t.type===e}function g(t){return typeof t.props!="object"||t.props===null||!("children"in t.props)?Promise.resolve([]):o(t.props.children)}async function I(t){return(await Promise.all(Array.from(t).map(o))).flat()}export{M as fromJsx};
1
+ function p(t,e){e&&Object.keys(e).length>0&&(t.style=e)}function s(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 l(t){let e={type:"image",src:t.src};return p(e,t.style),e}function f(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 S(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 x(t){return typeof t=="string"||typeof t=="number"}function E(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function C(t){return Object.keys(t).map(e=>`${e.replace(/([A-Z])/g,"-$1").toLowerCase()}:${String(t[e]).trim()}`).join(";")}var A=["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 T(t,e){if(t==="children"||e==null)return;let r;if(t==="className"?r="class":A.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="${E(o)}"`}return`${r}="${E(String(e))}"`}function $(t){return Object.entries(t).map(([e,r])=>T(e,r)).filter(e=>e!==void 0)}var v=(t,e)=>{let r=t.props||{},o=$(r),a=r.children,g=Array.isArray(a)?a.map(N=>e(N)).join(""):e(a);return`<${t.type}${o.length>0?` ${o.join(" ")}`:""}>${g}</${t.type}>`},c=t=>t==null||t===!1?"":x(t)?String(t):Array.isArray(t)?t.map(c).join(""):S(t)?v(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.transitional.element"),I=Symbol.for("react.element"),j=Symbol.for("react.forward_ref"),z=Symbol.for("react.memo");function F(t){return typeof t=="object"&&t!==null&&"$$typeof"in t&&(t.$$typeof===O||t.$$typeof===I)}async function U(t){let e=await i(t);return e.length===0?s({}):e.length===1&&e[0]!==void 0?e[0]:s({children:e,style:{width:f(100),height:f(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 X(t);if(F(t)){let e=await k(t);return Array.isArray(e)?e:e?[e]:[]}return[d(String(t))]}function w(t){return typeof t=="function"}function L(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof===j&&e.render)return i(e.render(t.props,null))}function W(t){if(typeof t.type!="object"||t.type===null)return;let e=t.type;if(e.$$typeof!==z)return;let r=e.type;if(w(r))return i(r(t.props));let o={...t,type:r};return k(o)}async function k(t){if(w(t.type))return i(t.type(t.props));let e=L(t);if(e!==void 0)return e;let r=W(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[_(t)];if(m(t,"svg"))return[M(t)];let o=await P(t),a=y(t.props);return typeof t.type=="string"&&t.type in u&&Object.assign(a,u[t.type]),[s({children:o,style:a})]}function _(t){if(!t.props.src)throw new Error("Image element must have a 'src' prop.");let e=y(t.props);return l({src:t.props.src,style:e})}function M(t){let e=y(t.props),r=b(t);return l({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 X(t){return(await Promise.all(Array.from(t).map(i))).flat()}export{U as fromJsx};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takumi-rs/helpers",
3
- "version": "0.28.0",
3
+ "version": "0.28.2",
4
4
  "author": {
5
5
  "email": "me@kane.tw",
6
6
  "name": "Kane Wang",
@@ -10,17 +10,15 @@
10
10
  "url": "git+https://github.com/kane50613/takumi.git"
11
11
  },
12
12
  "devDependencies": {
13
- "@types/bun": "catalog:",
13
+ "@types/bun": "^1.2.21",
14
14
  "@types/react": "^19.1.12",
15
15
  "@types/react-dom": "^19.1.9",
16
16
  "bun-plugin-dts": "^0.3.0",
17
17
  "lucide-react": "^0.542.0",
18
- "react": "^19.1.0",
18
+ "react": "^19.1.1",
19
+ "react-dom": "^19.1.1",
19
20
  "tsup": "^8.5.0",
20
- "typescript": "catalog:"
21
- },
22
- "peerDependencies": {
23
- "react-dom": "^19.0.0"
21
+ "typescript": "^5.9.2"
24
22
  },
25
23
  "exports": {
26
24
  ".": {
@@ -43,11 +41,6 @@
43
41
  "tsconfig.json"
44
42
  ],
45
43
  "license": "MIT",
46
- "peerDependenciesMeta": {
47
- "react-dom": {
48
- "optional": true
49
- }
50
- },
51
44
  "scripts": {
52
45
  "build": "tsup-node src/index.ts src/jsx/jsx.ts --minify --dts --format esm,cjs --no-splitting"
53
46
  },