@i.un/libs
Advanced tools
Comparing version 0.0.28 to 0.0.29
export * from "./dom"; | ||
export * from "./scroll"; | ||
export * from "./draggable"; |
@@ -1,2 +0,2 @@ | ||
const t=Symbol("undefined");function e(t){return"function"==typeof(null==t?void 0:t.clone)}function n(t){const e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function r(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function o(t){return n(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})})}function i(t){if(null===t||"object"!=typeof t)return t;if(e(t))return t.clone();if(Array.isArray(t))return t.map(t=>i(t));const n={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=i(t[e]));return n}function s(t,e){let n=null;return function(...r){const o=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{t.apply(o,r),n=null},e)}}function c(t,e=0){return new Promise(n=>{0===e?n(t()):setTimeout(()=>{n(t())},e)})}function u(t){return new Proxy({},{get:(e,n)=>e.hasOwnProperty(n)?e[n]:t})}const l=u(t),f=u(!1);function a(t){return l[t]}function d(e){return l[e]!==t}const p={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function y(t,e=p){return function(...n){const r=o(n)+t.name+(e.identifier||"");if(d(r))return Promise.resolve(i(a(r)));if(f[r]){const t=Object.assign({},p,e);return new Promise(e=>{const n=Date.now(),o=setInterval(()=>{d(r)?(clearInterval(o),e(i(a(r)))):Date.now()-n>t.timeout&&(f[r]=!1,clearInterval(o),e(i(t.timeoutResult)))},100)})}return f[r]=!0,t.apply(this,n).then(t=>(l[r]=t,i(l[r]))).catch(t=>{throw t}).finally(()=>{f[r]=!1})}}function m(e,n=0){const r=function r(...o){if(r.isExecuting)return Promise.resolve(t);r.isExecuting=!0;const i=performance.now(),s=e.apply(this,o);return s.finally(()=>{const t=performance.now()-i;n&&n>t?setTimeout(()=>{r.isExecuting=!1},n-t):r.isExecuting=!1}),s};return r.isExecuting=!1,r}function g(t,e,n,r=!1){if(e in t.style)t.style[e]=n;else{const o=r?"important":"";t.style.setProperty(e,String(n),o)}}function h({tag:t="div",children:e=[],props:n={},attrs:r={},styles:o={}}={}){const i=document.createElement(t);Object.assign(i,n);for(const[t,e]of Object.entries(r))!1!==e&&i.setAttribute(t,e);for(const[t,e]of Object.entries(o))g(i,t,e);const s=Array.isArray(e)?e:[e];for(const t of s)t&&("object"==typeof t?t instanceof Element?i.appendChild(t):i.appendChild(h(t)):i.appendChild(document.createTextNode(t)));return i}function w(t){const e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(const[n,r]of Object.entries(t.props))e.setAttribute(n,r);if("string"==typeof t.children){const n=document.createTextNode(t.children);e.appendChild(n)}else Array.isArray(t.children)&&t.children.forEach(t=>{const n=w(t);e.appendChild(n)});return e}function b(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function E(t){return"string"==typeof t?b(t):w(t)}async function x(t){try{const e=await fetch(t);if(!e.ok)throw new Error(`网络请求失败: ${e.status} ${e.statusText}`);return b(await e.text())}catch(t){const e=t instanceof Error?t.message:"未知错误";throw new Error(`无法创建 SVG 元素: ${e}`)}}function T(t){t&&setTimeout(()=>{t.scrollTop=t.scrollHeight},0)}function O(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",()=>{!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&T(t))}export{t as RealUndefined,y as cacheWrapper,i as cloneDeep,u as createDefaultObject,h as createElement,E as createSvg,x as createSvgFromUrl,s as debounce,c as delayExecution,o as generateStableUniqueKey,r as getGlobal,e as isCloneable,n as isPrimitive,T as scrollToBottom,O as scrollToBottomIfNeeded,m as singleExecutionWrapper}; | ||
const t=Symbol("undefined");function e(t){return"function"==typeof(null==t?void 0:t.clone)}function n(t){const e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function i(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function o(t){return n(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})})}function s(t){if(null===t||"object"!=typeof t)return t;if(e(t))return t.clone();if(Array.isArray(t))return t.map(t=>s(t));const n={};for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(n[e]=s(t[e]));return n}function r(t,e){let n=null;return function(...i){const o=this;null!==n&&clearTimeout(n),n=setTimeout(()=>{t.apply(o,i),n=null},e)}}function u(t,e=0){return new Promise(n=>{0===e?n(t()):setTimeout(()=>{n(t())},e)})}function c(t){return new Proxy({},{get:(e,n)=>e.hasOwnProperty(n)?e[n]:t})}const l=c(t),a=c(!1);function h(t){return l[t]}function d(e){return l[e]!==t}const f={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function p(t,e=f){return function(...n){const i=o(n)+t.name+(e.identifier||"");if(d(i))return Promise.resolve(s(h(i)));if(a[i]){const t=Object.assign({},f,e);return new Promise(e=>{const n=Date.now(),o=setInterval(()=>{d(i)?(clearInterval(o),e(s(h(i)))):Date.now()-n>t.timeout&&(a[i]=!1,clearInterval(o),e(s(t.timeoutResult)))},100)})}return a[i]=!0,t.apply(this,n).then(t=>(l[i]=t,s(l[i]))).catch(t=>{throw t}).finally(()=>{a[i]=!1})}}function m(e,n=0){const i=function i(...o){if(i.isExecuting)return Promise.resolve(t);i.isExecuting=!0;const s=performance.now(),r=e.apply(this,o);return r.finally(()=>{const t=performance.now()-s;n&&n>t?setTimeout(()=>{i.isExecuting=!1},n-t):i.isExecuting=!1}),r};return i.isExecuting=!1,i}function g(t,e,n,i=!1){if(e in t.style)t.style[e]=n;else{const o=i?"important":"";t.style.setProperty(e,String(n),o)}}function y({tag:t="div",children:e=[],props:n={},attrs:i={},styles:o={}}={}){const s=document.createElement(t);Object.assign(s,n);for(const[t,e]of Object.entries(i))!1!==e&&s.setAttribute(t,e);for(const[t,e]of Object.entries(o))g(s,t,e);const r=Array.isArray(e)?e:[e];for(const t of r)t&&("object"==typeof t?t instanceof Element?s.appendChild(t):s.appendChild(y(t)):s.appendChild(document.createTextNode(t)));return s}function w(t){const e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(const[n,i]of Object.entries(t.props))e.setAttribute(n,i);if("string"==typeof t.children){const n=document.createTextNode(t.children);e.appendChild(n)}else Array.isArray(t.children)&&t.children.forEach(t=>{const n=w(t);e.appendChild(n)});return e}function v(t){const e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function b(t){return"string"==typeof t?v(t):w(t)}async function E(t){try{const e=await fetch(t);if(!e.ok)throw new Error(`网络请求失败: ${e.status} ${e.statusText}`);return v(await e.text())}catch(t){const e=t instanceof Error?t.message:"未知错误";throw new Error(`无法创建 SVG 元素: ${e}`)}}function M(t){t&&setTimeout(()=>{t.scrollTop=t.scrollHeight},0)}function D(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",()=>{!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&M(t))}class S{constructor(t,e={}){this.element=void 0,this.options=void 0,this.isDragging=!1,this.startX=0,this.startY=0,this.initialX=0,this.initialY=0,this.threshold=5,this.onMouseMoveHandler=void 0,this.onMouseUpHandler=void 0,this.element=t,this.options=e,this.element.style.position="absolute",this.onMouseMoveHandler=this.onMouseMove.bind(this),this.onMouseUpHandler=this.onMouseUp.bind(this),this.element.addEventListener("mousedown",this.onMouseDown.bind(this))}onMouseDown(t){t.preventDefault(),this.startX=t.clientX,this.startY=t.clientY,this.initialX=parseInt(window.getComputedStyle(this.element).left,10)||0,this.initialY=parseInt(window.getComputedStyle(this.element).top,10)||0,document.addEventListener("mousemove",this.onMouseMoveHandler),document.addEventListener("mouseup",this.onMouseUpHandler)}onMouseMove(t){if(!this.isDragging){const e=t.clientY-this.startY;(Math.abs(t.clientX-this.startX)>this.threshold||Math.abs(e)>this.threshold)&&(this.isDragging=!0,this.options.onDragStart&&this.options.onDragStart(t))}if(this.isDragging){const e=t.clientY-this.startY;this.element.style.left=this.initialX+(t.clientX-this.startX)+"px",this.element.style.top=this.initialY+e+"px",this.options.onDrag&&this.options.onDrag(t)}}onMouseUp(t){this.isDragging&&this.options.onDragEnd&&this.options.onDragEnd(t),this.isDragging=!1,document.removeEventListener("mousemove",this.onMouseMoveHandler),document.removeEventListener("mouseup",this.onMouseUpHandler)}}export{S as Draggable,t as RealUndefined,p as cacheWrapper,s as cloneDeep,c as createDefaultObject,y as createElement,b as createSvg,E as createSvgFromUrl,r as debounce,u as delayExecution,o as generateStableUniqueKey,i as getGlobal,e as isCloneable,n as isPrimitive,M as scrollToBottom,D as scrollToBottomIfNeeded,m as singleExecutionWrapper}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
var e=Symbol("undefined");function t(e){return"function"==typeof(null==e?void 0:e.clone)}function r(e){var t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function n(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function o(e){return r(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(e,r){return e[r]=t[r],e},{})})}function i(e){if(null===e||"object"!=typeof e)return e;if(t(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return i(e)});var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=i(e[n]));return r}function u(e,t){var r=null;return function(){var n=arguments,o=this;null!==r&&clearTimeout(r),r=setTimeout(function(){e.apply(o,[].slice.call(n)),r=null},t)}}function a(e,t){return void 0===t&&(t=0),new Promise(function(r){0===t?r(e()):setTimeout(function(){r(e())},t)})}function c(e){return new Proxy({},{get:function(t,r){return t.hasOwnProperty(r)?t[r]:e}})}var l=c(e),s=c(!1);function f(e){return l[e]}function d(t){return l[t]!==e}var v={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function p(e,t){return void 0===t&&(t=v),function(){var r=[].slice.call(arguments),n=o(r)+e.name+(t.identifier||"");if(d(n))return Promise.resolve(i(f(n)));if(s[n]){var u=Object.assign({},v,t);return new Promise(function(e){var t=Date.now(),r=setInterval(function(){d(n)?(clearInterval(r),e(i(f(n)))):Date.now()-t>u.timeout&&(s[n]=!1,clearInterval(r),e(i(u.timeoutResult)))},100)})}return s[n]=!0,e.apply(this,r).then(function(e){return l[n]=e,i(l[n])}).catch(function(e){throw e}).finally(function(){s[n]=!1})}}function y(t,r){void 0===r&&(r=0);var n=function(){if(n.isExecuting)return Promise.resolve(e);n.isExecuting=!0;var o=performance.now(),i=t.apply(this,[].slice.call(arguments));return i.finally(function(){var e=performance.now()-o;r&&r>e?setTimeout(function(){n.isExecuting=!1},r-e):n.isExecuting=!1}),i};return n.isExecuting=!1,n}function m(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function h(e,t,r,n){if(void 0===n&&(n=!1),t in e.style)e.style[t]=r;else{var o=n?"important":"";e.style.setProperty(t,String(r),o)}}var g=function(e){try{return Promise.resolve(function(t,r){try{var n=Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("网络请求失败: "+e.status+" "+e.statusText);return Promise.resolve(e.text()).then(E)})}catch(e){return r(e)}return n&&n.then?n.then(void 0,r):n}(0,function(e){var t=e instanceof Error?e.message:"未知错误";throw new Error("无法创建 SVG 元素: "+t)}))}catch(e){return Promise.reject(e)}};function b(e){var t=void 0===e?{}:e,r=t.tag,n=t.children,o=void 0===n?[]:n,i=t.props,u=void 0===i?{}:i,a=t.attrs,c=void 0===a?{}:a,l=t.styles,s=void 0===l?{}:l,f=document.createElement(void 0===r?"div":r);Object.assign(f,u);for(var d=0,v=Object.entries(c);d<v.length;d++){var p=v[d],y=p[1];!1!==y&&f.setAttribute(p[0],y)}for(var g=0,w=Object.entries(s);g<w.length;g++){var E=w[g];h(f,E[0],E[1])}for(var A,S=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return m(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?m(e,t):void 0}}(e))){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(o)?o:[o]);!(A=S()).done;){var j=A.value;j&&("object"==typeof j?j instanceof Element?f.appendChild(j):f.appendChild(b(j)):f.appendChild(document.createTextNode(j)))}return f}function w(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(var r=0,n=Object.entries(e.props);r<n.length;r++){var o=n[r];t.setAttribute(o[0],o[1])}if("string"==typeof e.children){var i=document.createTextNode(e.children);t.appendChild(i)}else Array.isArray(e.children)&&e.children.forEach(function(e){var r=w(e);t.appendChild(r)});return t}function E(e){var t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function A(e){return"string"==typeof e?E(e):w(e)}function S(e){e&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)}function j(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",function(){!function(e,t){e.dataset.userInteracted=t?"true":"false"}(e,e.scrollTop+e.clientHeight<e.scrollHeight-5)})}(e),e.dataset.isListeningForUserScroll="true"),"true"!==e.dataset.userInteracted&&S(e))}export{e as RealUndefined,p as cacheWrapper,i as cloneDeep,c as createDefaultObject,b as createElement,A as createSvg,g as createSvgFromUrl,u as debounce,a as delayExecution,o as generateStableUniqueKey,n as getGlobal,t as isCloneable,r as isPrimitive,S as scrollToBottom,j as scrollToBottomIfNeeded,y as singleExecutionWrapper}; | ||
var t=Symbol("undefined");function e(t){return"function"==typeof(null==t?void 0:t.clone)}function n(t){var e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function r(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this}function i(t){return n(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})})}function o(t){if(null===t||"object"!=typeof t)return t;if(e(t))return t.clone();if(Array.isArray(t))return t.map(function(t){return o(t)});var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(n[r]=o(t[r]));return n}function s(t,e){var n=null;return function(){var r=arguments,i=this;null!==n&&clearTimeout(n),n=setTimeout(function(){t.apply(i,[].slice.call(r)),n=null},e)}}function a(t,e){return void 0===e&&(e=0),new Promise(function(n){0===e?n(t()):setTimeout(function(){n(t())},e)})}function u(t){return new Proxy({},{get:function(e,n){return e.hasOwnProperty(n)?e[n]:t}})}var l=u(t),c=u(!1);function f(t){return l[t]}function d(e){return l[e]!==t}var h={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function v(t,e){return void 0===e&&(e=h),function(){var n=[].slice.call(arguments),r=i(n)+t.name+(e.identifier||"");if(d(r))return Promise.resolve(o(f(r)));if(c[r]){var s=Object.assign({},h,e);return new Promise(function(t){var e=Date.now(),n=setInterval(function(){d(r)?(clearInterval(n),t(o(f(r)))):Date.now()-e>s.timeout&&(c[r]=!1,clearInterval(n),t(o(s.timeoutResult)))},100)})}return c[r]=!0,t.apply(this,n).then(function(t){return l[r]=t,o(l[r])}).catch(function(t){throw t}).finally(function(){c[r]=!1})}}function p(e,n){void 0===n&&(n=0);var r=function(){if(r.isExecuting)return Promise.resolve(t);r.isExecuting=!0;var i=performance.now(),o=e.apply(this,[].slice.call(arguments));return o.finally(function(){var t=performance.now()-i;n&&n>t?setTimeout(function(){r.isExecuting=!1},n-t):r.isExecuting=!1}),o};return r.isExecuting=!1,r}function m(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function g(t,e,n,r){if(void 0===r&&(r=!1),e in t.style)t.style[e]=n;else{var i=r?"important":"";t.style.setProperty(e,String(n),i)}}var y=function(t){try{return Promise.resolve(function(e,n){try{var r=Promise.resolve(fetch(t)).then(function(t){if(!t.ok)throw new Error("网络请求失败: "+t.status+" "+t.statusText);return Promise.resolve(t.text()).then(E)})}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(t){var e=t instanceof Error?t.message:"未知错误";throw new Error("无法创建 SVG 元素: "+e)}))}catch(t){return Promise.reject(t)}};function b(t){var e=void 0===t?{}:t,n=e.tag,r=e.children,i=void 0===r?[]:r,o=e.props,s=void 0===o?{}:o,a=e.attrs,u=void 0===a?{}:a,l=e.styles,c=void 0===l?{}:l,f=document.createElement(void 0===n?"div":n);Object.assign(f,s);for(var d=0,h=Object.entries(u);d<h.length;d++){var v=h[d],p=v[1];!1!==p&&f.setAttribute(v[0],p)}for(var y=0,w=Object.entries(c);y<w.length;y++){var E=w[y];g(f,E[0],E[1])}for(var M,S=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return m(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?m(t,e):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(M=S()).done;){var D=M.value;D&&("object"==typeof D?D instanceof Element?f.appendChild(D):f.appendChild(b(D)):f.appendChild(document.createTextNode(D)))}return f}function w(t){var e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(var n=0,r=Object.entries(t.props);n<r.length;n++){var i=r[n];e.setAttribute(i[0],i[1])}if("string"==typeof t.children){var o=document.createTextNode(t.children);e.appendChild(o)}else Array.isArray(t.children)&&t.children.forEach(function(t){var n=w(t);e.appendChild(n)});return e}function E(t){var e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function M(t){return"string"==typeof t?E(t):w(t)}function S(t){t&&setTimeout(function(){t.scrollTop=t.scrollHeight},0)}function D(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",function(){!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&S(t))}var A=/*#__PURE__*/function(){function t(t,e){void 0===e&&(e={}),this.element=void 0,this.options=void 0,this.isDragging=!1,this.startX=0,this.startY=0,this.initialX=0,this.initialY=0,this.threshold=5,this.onMouseMoveHandler=void 0,this.onMouseUpHandler=void 0,this.element=t,this.options=e,this.element.style.position="absolute",this.onMouseMoveHandler=this.onMouseMove.bind(this),this.onMouseUpHandler=this.onMouseUp.bind(this),this.element.addEventListener("mousedown",this.onMouseDown.bind(this))}var e=t.prototype;return e.onMouseDown=function(t){t.preventDefault(),this.startX=t.clientX,this.startY=t.clientY,this.initialX=parseInt(window.getComputedStyle(this.element).left,10)||0,this.initialY=parseInt(window.getComputedStyle(this.element).top,10)||0,document.addEventListener("mousemove",this.onMouseMoveHandler),document.addEventListener("mouseup",this.onMouseUpHandler)},e.onMouseMove=function(t){if(!this.isDragging){var e=t.clientY-this.startY;(Math.abs(t.clientX-this.startX)>this.threshold||Math.abs(e)>this.threshold)&&(this.isDragging=!0,this.options.onDragStart&&this.options.onDragStart(t))}if(this.isDragging){var n=t.clientY-this.startY;this.element.style.left=this.initialX+(t.clientX-this.startX)+"px",this.element.style.top=this.initialY+n+"px",this.options.onDrag&&this.options.onDrag(t)}},e.onMouseUp=function(t){this.isDragging&&this.options.onDragEnd&&this.options.onDragEnd(t),this.isDragging=!1,document.removeEventListener("mousemove",this.onMouseMoveHandler),document.removeEventListener("mouseup",this.onMouseUpHandler)},t}();export{A as Draggable,t as RealUndefined,v as cacheWrapper,o as cloneDeep,u as createDefaultObject,b as createElement,M as createSvg,y as createSvgFromUrl,s as debounce,a as delayExecution,i as generateStableUniqueKey,r as getGlobal,e as isCloneable,n as isPrimitive,S as scrollToBottom,D as scrollToBottomIfNeeded,p as singleExecutionWrapper}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).iunLibs={})}(this,function(e){var t=Symbol("undefined");function n(e){return"function"==typeof(null==e?void 0:e.clone)}function r(e){var t=typeof e;return null===e||"string"===t||"number"===t||"boolean"===t||"undefined"===t}function o(e){return r(e)?String(e):JSON.stringify(e,function(e,t){return"object"!=typeof t||null===t||Array.isArray(t)?t:Object.keys(t).sort().reduce(function(e,n){return e[n]=t[n],e},{})})}function i(e){if(null===e||"object"!=typeof e)return e;if(n(e))return e.clone();if(Array.isArray(e))return e.map(function(e){return i(e)});var t={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=i(e[r]));return t}function u(e){return new Proxy({},{get:function(t,n){return t.hasOwnProperty(n)?t[n]:e}})}var a=u(t),c=u(!1);function l(e){return a[e]}function s(e){return a[e]!==t}var f={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v(e,t,n,r){if(void 0===r&&(r=!1),t in e.style)e.style[t]=n;else{var o=r?"important":"";e.style.setProperty(t,String(n),o)}}function p(e){var t=document.createElementNS("http://www.w3.org/2000/svg",e.type);if(e.props)for(var n=0,r=Object.entries(e.props);n<r.length;n++){var o=r[n];t.setAttribute(o[0],o[1])}if("string"==typeof e.children){var i=document.createTextNode(e.children);t.appendChild(i)}else Array.isArray(e.children)&&e.children.forEach(function(e){var n=p(e);t.appendChild(n)});return t}function y(e){var t=(new DOMParser).parseFromString(e,"image/svg+xml").documentElement;if(!(t instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return t}function m(e){e&&setTimeout(function(){e.scrollTop=e.scrollHeight},0)}e.RealUndefined=t,e.cacheWrapper=function(e,t){return void 0===t&&(t=f),function(){var n=[].slice.call(arguments),r=o(n)+e.name+(t.identifier||"");if(s(r))return Promise.resolve(i(l(r)));if(c[r]){var u=Object.assign({},f,t);return new Promise(function(e){var t=Date.now(),n=setInterval(function(){s(r)?(clearInterval(n),e(i(l(r)))):Date.now()-t>u.timeout&&(c[r]=!1,clearInterval(n),e(i(u.timeoutResult)))},100)})}return c[r]=!0,e.apply(this,n).then(function(e){return a[r]=e,i(a[r])}).catch(function(e){throw e}).finally(function(){c[r]=!1})}},e.cloneDeep=i,e.createDefaultObject=u,e.createElement=function e(t){var n=void 0===t?{}:t,r=n.tag,o=n.children,i=void 0===o?[]:o,u=n.props,a=void 0===u?{}:u,c=n.attrs,l=void 0===c?{}:c,s=n.styles,f=void 0===s?{}:s,p=document.createElement(void 0===r?"div":r);Object.assign(p,a);for(var y=0,m=Object.entries(l);y<m.length;y++){var h=m[y],g=h[1];!1!==g&&p.setAttribute(h[0],g)}for(var b=0,w=Object.entries(f);b<w.length;b++){var E=w[b];v(p,E[0],E[1])}for(var S,x=function(e){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,t){if(e){if("string"==typeof e)return d(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}(e))){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(i)?i:[i]);!(S=x()).done;){var T=S.value;T&&("object"==typeof T?T instanceof Element?p.appendChild(T):p.appendChild(e(T)):p.appendChild(document.createTextNode(T)))}return p},e.createSvg=function(e){return"string"==typeof e?y(e):p(e)},e.createSvgFromUrl=function(e){try{return Promise.resolve(function(t,n){try{var r=Promise.resolve(fetch(e)).then(function(e){if(!e.ok)throw new Error("网络请求失败: "+e.status+" "+e.statusText);return Promise.resolve(e.text()).then(y)})}catch(e){return n(e)}return r&&r.then?r.then(void 0,n):r}(0,function(e){var t=e instanceof Error?e.message:"未知错误";throw new Error("无法创建 SVG 元素: "+t)}))}catch(e){return Promise.reject(e)}},e.debounce=function(e,t){var n=null;return function(){var r=arguments,o=this;null!==n&&clearTimeout(n),n=setTimeout(function(){e.apply(o,[].slice.call(r)),n=null},t)}},e.delayExecution=function(e,t){return void 0===t&&(t=0),new Promise(function(n){0===t?n(e()):setTimeout(function(){n(e())},t)})},e.generateStableUniqueKey=o,e.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},e.isCloneable=n,e.isPrimitive=r,e.scrollToBottom=m,e.scrollToBottomIfNeeded=function(e){e&&("true"!==e.dataset.isListeningForUserScroll&&(function(e){e&&e.addEventListener("scroll",function(){!function(e,t){e.dataset.userInteracted=t?"true":"false"}(e,e.scrollTop+e.clientHeight<e.scrollHeight-5)})}(e),e.dataset.isListeningForUserScroll="true"),"true"!==e.dataset.userInteracted&&m(e))},e.singleExecutionWrapper=function(e,n){void 0===n&&(n=0);var r=function(){if(r.isExecuting)return Promise.resolve(t);r.isExecuting=!0;var o=performance.now(),i=e.apply(this,[].slice.call(arguments));return i.finally(function(){var e=performance.now()-o;n&&n>e?setTimeout(function(){r.isExecuting=!1},n-e):r.isExecuting=!1}),i};return r.isExecuting=!1,r}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).iunLibs={})}(this,function(t){var e=Symbol("undefined");function n(t){return"function"==typeof(null==t?void 0:t.clone)}function r(t){var e=typeof t;return null===t||"string"===e||"number"===e||"boolean"===e||"undefined"===e}function i(t){return r(t)?String(t):JSON.stringify(t,function(t,e){return"object"!=typeof e||null===e||Array.isArray(e)?e:Object.keys(e).sort().reduce(function(t,n){return t[n]=e[n],t},{})})}function o(t){if(null===t||"object"!=typeof t)return t;if(n(t))return t.clone();if(Array.isArray(t))return t.map(function(t){return o(t)});var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=o(t[r]));return e}function s(t){return new Proxy({},{get:function(e,n){return e.hasOwnProperty(n)?e[n]:t}})}var a=s(e),u=s(!1);function l(t){return a[t]}function c(t){return a[t]!==e}var f={timeout:6e4,timeoutResult:{code:408,msg:"请求超时"},identifier:""};function d(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function h(t,e,n,r){if(void 0===r&&(r=!1),e in t.style)t.style[e]=n;else{var i=r?"important":"";t.style.setProperty(e,String(n),i)}}function p(t){var e=document.createElementNS("http://www.w3.org/2000/svg",t.type);if(t.props)for(var n=0,r=Object.entries(t.props);n<r.length;n++){var i=r[n];e.setAttribute(i[0],i[1])}if("string"==typeof t.children){var o=document.createTextNode(t.children);e.appendChild(o)}else Array.isArray(t.children)&&t.children.forEach(function(t){var n=p(t);e.appendChild(n)});return e}function v(t){var e=(new DOMParser).parseFromString(t,"image/svg+xml").documentElement;if(!(e instanceof SVGElement))throw new Error("解析失败,结果不是有效的 SVG 元素");return e}function m(t){t&&setTimeout(function(){t.scrollTop=t.scrollHeight},0)}t.Draggable=/*#__PURE__*/function(){function t(t,e){void 0===e&&(e={}),this.element=void 0,this.options=void 0,this.isDragging=!1,this.startX=0,this.startY=0,this.initialX=0,this.initialY=0,this.threshold=5,this.onMouseMoveHandler=void 0,this.onMouseUpHandler=void 0,this.element=t,this.options=e,this.element.style.position="absolute",this.onMouseMoveHandler=this.onMouseMove.bind(this),this.onMouseUpHandler=this.onMouseUp.bind(this),this.element.addEventListener("mousedown",this.onMouseDown.bind(this))}var e=t.prototype;return e.onMouseDown=function(t){t.preventDefault(),this.startX=t.clientX,this.startY=t.clientY,this.initialX=parseInt(window.getComputedStyle(this.element).left,10)||0,this.initialY=parseInt(window.getComputedStyle(this.element).top,10)||0,document.addEventListener("mousemove",this.onMouseMoveHandler),document.addEventListener("mouseup",this.onMouseUpHandler)},e.onMouseMove=function(t){if(!this.isDragging){var e=t.clientY-this.startY;(Math.abs(t.clientX-this.startX)>this.threshold||Math.abs(e)>this.threshold)&&(this.isDragging=!0,this.options.onDragStart&&this.options.onDragStart(t))}if(this.isDragging){var n=t.clientY-this.startY;this.element.style.left=this.initialX+(t.clientX-this.startX)+"px",this.element.style.top=this.initialY+n+"px",this.options.onDrag&&this.options.onDrag(t)}},e.onMouseUp=function(t){this.isDragging&&this.options.onDragEnd&&this.options.onDragEnd(t),this.isDragging=!1,document.removeEventListener("mousemove",this.onMouseMoveHandler),document.removeEventListener("mouseup",this.onMouseUpHandler)},t}(),t.RealUndefined=e,t.cacheWrapper=function(t,e){return void 0===e&&(e=f),function(){var n=[].slice.call(arguments),r=i(n)+t.name+(e.identifier||"");if(c(r))return Promise.resolve(o(l(r)));if(u[r]){var s=Object.assign({},f,e);return new Promise(function(t){var e=Date.now(),n=setInterval(function(){c(r)?(clearInterval(n),t(o(l(r)))):Date.now()-e>s.timeout&&(u[r]=!1,clearInterval(n),t(o(s.timeoutResult)))},100)})}return u[r]=!0,t.apply(this,n).then(function(t){return a[r]=t,o(a[r])}).catch(function(t){throw t}).finally(function(){u[r]=!1})}},t.cloneDeep=o,t.createDefaultObject=s,t.createElement=function t(e){var n=void 0===e?{}:e,r=n.tag,i=n.children,o=void 0===i?[]:i,s=n.props,a=void 0===s?{}:s,u=n.attrs,l=void 0===u?{}:u,c=n.styles,f=void 0===c?{}:c,p=document.createElement(void 0===r?"div":r);Object.assign(p,a);for(var v=0,m=Object.entries(l);v<m.length;v++){var g=m[v],y=g[1];!1!==y&&p.setAttribute(g[0],y)}for(var b=0,w=Object.entries(f);b<w.length;b++){var E=w[b];h(p,E[0],E[1])}for(var M,S=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return d(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(t,e):void 0}}(t))){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(Array.isArray(o)?o:[o]);!(M=S()).done;){var D=M.value;D&&("object"==typeof D?D instanceof Element?p.appendChild(D):p.appendChild(t(D)):p.appendChild(document.createTextNode(D)))}return p},t.createSvg=function(t){return"string"==typeof t?v(t):p(t)},t.createSvgFromUrl=function(t){try{return Promise.resolve(function(e,n){try{var r=Promise.resolve(fetch(t)).then(function(t){if(!t.ok)throw new Error("网络请求失败: "+t.status+" "+t.statusText);return Promise.resolve(t.text()).then(v)})}catch(t){return n(t)}return r&&r.then?r.then(void 0,n):r}(0,function(t){var e=t instanceof Error?t.message:"未知错误";throw new Error("无法创建 SVG 元素: "+e)}))}catch(t){return Promise.reject(t)}},t.debounce=function(t,e){var n=null;return function(){var r=arguments,i=this;null!==n&&clearTimeout(n),n=setTimeout(function(){t.apply(i,[].slice.call(r)),n=null},e)}},t.delayExecution=function(t,e){return void 0===e&&(e=0),new Promise(function(n){0===e?n(t()):setTimeout(function(){n(t())},e)})},t.generateStableUniqueKey=i,t.getGlobal=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:this},t.isCloneable=n,t.isPrimitive=r,t.scrollToBottom=m,t.scrollToBottomIfNeeded=function(t){t&&("true"!==t.dataset.isListeningForUserScroll&&(function(t){t&&t.addEventListener("scroll",function(){!function(t,e){t.dataset.userInteracted=e?"true":"false"}(t,t.scrollTop+t.clientHeight<t.scrollHeight-5)})}(t),t.dataset.isListeningForUserScroll="true"),"true"!==t.dataset.userInteracted&&m(t))},t.singleExecutionWrapper=function(t,n){void 0===n&&(n=0);var r=function(){if(r.isExecuting)return Promise.resolve(e);r.isExecuting=!0;var i=performance.now(),o=t.apply(this,[].slice.call(arguments));return o.finally(function(){var t=performance.now()-i;n&&n>t?setTimeout(function(){r.isExecuting=!1},n-t):r.isExecuting=!1}),o};return r.isExecuting=!1,r}}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@i.un/libs", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"description": "一个实用的ts函数库", | ||
@@ -5,0 +5,0 @@ "type": "module", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
167224
26
402
5