@takumi-rs/helpers 0.28.1 → 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 +1 -1
- package/dist/jsx/jsx.js +1 -1
- package/package.json +5 -12
package/dist/jsx/jsx.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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,"&").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 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
|
-
|
|
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,"&").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 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.
|
|
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": "
|
|
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.
|
|
18
|
+
"react": "^19.1.1",
|
|
19
|
+
"react-dom": "^19.1.1",
|
|
19
20
|
"tsup": "^8.5.0",
|
|
20
|
-
"typescript": "
|
|
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
|
},
|